Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
opencompass
Commits
fb111087
"...resnet50_tensorflow.git" did not exist on "7f5cc3cec1760ce3c4340e8e31bc1a0552d0408b"
Commit
fb111087
authored
Jul 04, 2023
by
yingfhu
Browse files
[Feat] support opencompass
parent
7d346000
Changes
81
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
opencompass/utils/types.py
opencompass/utils/types.py
+45
-0
No files found.
opencompass/utils/types.py
0 → 100644
View file @
fb111087
from
typing
import
Dict
,
List
,
Union
from
datasets
import
Dataset
,
DatasetDict
def
_check_type_list
(
obj
,
typelist
:
List
):
for
_type
in
typelist
:
if
_type
is
None
:
if
obj
is
None
:
return
obj
elif
isinstance
(
obj
,
_type
):
return
obj
raise
TypeError
(
f
'Expected an object in
{
[
_
.
__name__
if
_
is
not
None
else
None
for
_
in
typelist
]
}
type, but got
{
obj
}
'
)
def
_check_dataset
(
obj
)
->
Union
[
Dataset
,
DatasetDict
]:
if
isinstance
(
obj
,
Dataset
)
or
isinstance
(
obj
,
DatasetDict
):
return
obj
else
:
raise
TypeError
(
f
'Expected a datasets.Dataset or a datasets.DatasetDict object, but got
{
obj
}
'
)
def
_check_list
(
obj
)
->
List
:
if
isinstance
(
obj
,
List
):
return
obj
else
:
raise
TypeError
(
f
'Expected a List object, but got
{
obj
}
'
)
def
_check_str
(
obj
)
->
str
:
if
isinstance
(
obj
,
str
):
return
obj
else
:
raise
TypeError
(
f
'Expected a str object, but got
{
obj
}
'
)
def
_check_dict
(
obj
)
->
Dict
:
if
isinstance
(
obj
,
Dict
):
return
obj
else
:
raise
TypeError
(
f
'Expected a Dict object, but got
{
obj
}
'
)
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment