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
chenpangpang
transformers
Commits
59611a0f
Unverified
Commit
59611a0f
authored
Jan 30, 2023
by
amyeroberts
Committed by
GitHub
Jan 30, 2023
Browse files
Fix DETR tests after #21144 (#21365)
* Fix annotation check * Fix annotation check * Update type annotations
parent
7a2e1320
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
src/transformers/models/conditional_detr/image_processing_conditional_detr.py
...els/conditional_detr/image_processing_conditional_detr.py
+6
-3
src/transformers/models/deformable_detr/image_processing_deformable_detr.py
...odels/deformable_detr/image_processing_deformable_detr.py
+6
-3
src/transformers/models/detr/image_processing_detr.py
src/transformers/models/detr/image_processing_detr.py
+6
-3
src/transformers/models/yolos/image_processing_yolos.py
src/transformers/models/yolos/image_processing_yolos.py
+6
-3
No files found.
src/transformers/models/conditional_detr/image_processing_conditional_detr.py
View file @
59611a0f
...
...
@@ -77,6 +77,9 @@ if is_scipy_available():
import
scipy.stats
AnnotationType
=
Dict
[
str
,
Union
[
int
,
str
,
List
[
Dict
]]]
class
AnnotionFormat
(
ExplicitEnum
):
COCO_DETECTION
=
"coco_detection"
COCO_PANOPTIC
=
"coco_panoptic"
...
...
@@ -1071,7 +1074,7 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
def
preprocess
(
self
,
images
:
ImageInput
,
annotations
:
Optional
[
Union
[
List
[
Dict
],
List
[
List
[
Dict
]
]]]
=
None
,
annotations
:
Optional
[
Union
[
AnnotationType
,
List
[
AnnotationType
]]]
=
None
,
return_segmentation_masks
:
bool
=
None
,
masks_path
:
Optional
[
Union
[
str
,
pathlib
.
Path
]]
=
None
,
do_resize
:
Optional
[
bool
]
=
None
,
...
...
@@ -1094,7 +1097,7 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
Args:
images (`ImageInput`):
Image or batch of images to preprocess.
annotations (`
List[Dict]` or `List[List[Dict]
]`, *optional*):
annotations (`
AnnotationType` or `List[AnnotationType
]`, *optional*):
List of annotations associated with the image or batch of images. If annotionation is for object
detection, the annotations should be a dictionary with the following keys:
- "image_id" (`int`): The image id.
...
...
@@ -1173,7 +1176,7 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
raise
ValueError
(
"Image mean and std must be specified if do_normalize is True."
)
images
=
make_list_of_images
(
images
)
if
annotations
is
not
None
and
isinstance
(
annotations
[
0
]
,
dict
):
if
annotations
is
not
None
and
isinstance
(
annotations
,
dict
):
annotations
=
[
annotations
]
if
annotations
is
not
None
and
len
(
images
)
!=
len
(
annotations
):
...
...
src/transformers/models/deformable_detr/image_processing_deformable_detr.py
View file @
59611a0f
...
...
@@ -76,6 +76,9 @@ if is_scipy_available():
import
scipy.stats
AnnotationType
=
Dict
[
str
,
Union
[
int
,
str
,
List
[
Dict
]]]
class
AnnotionFormat
(
ExplicitEnum
):
COCO_DETECTION
=
"coco_detection"
COCO_PANOPTIC
=
"coco_panoptic"
...
...
@@ -1069,7 +1072,7 @@ class DeformableDetrImageProcessor(BaseImageProcessor):
def
preprocess
(
self
,
images
:
ImageInput
,
annotations
:
Optional
[
Union
[
List
[
Dict
],
List
[
List
[
Dict
]
]]]
=
None
,
annotations
:
Optional
[
Union
[
AnnotationType
,
List
[
AnnotationType
]]]
=
None
,
return_segmentation_masks
:
bool
=
None
,
masks_path
:
Optional
[
Union
[
str
,
pathlib
.
Path
]]
=
None
,
do_resize
:
Optional
[
bool
]
=
None
,
...
...
@@ -1092,7 +1095,7 @@ class DeformableDetrImageProcessor(BaseImageProcessor):
Args:
images (`ImageInput`):
Image or batch of images to preprocess.
annotations (`
List[Dict]` or `List[List[Dict]
]`, *optional*):
annotations (`
AnnotationType` or `List[AnnotationType
]`, *optional*):
List of annotations associated with the image or batch of images. If annotionation is for object
detection, the annotations should be a dictionary with the following keys:
- "image_id" (`int`): The image id.
...
...
@@ -1171,7 +1174,7 @@ class DeformableDetrImageProcessor(BaseImageProcessor):
raise
ValueError
(
"Image mean and std must be specified if do_normalize is True."
)
images
=
make_list_of_images
(
images
)
if
annotations
is
not
None
and
isinstance
(
annotations
[
0
]
,
dict
):
if
annotations
is
not
None
and
isinstance
(
annotations
,
dict
):
annotations
=
[
annotations
]
if
annotations
is
not
None
and
len
(
images
)
!=
len
(
annotations
):
...
...
src/transformers/models/detr/image_processing_detr.py
View file @
59611a0f
...
...
@@ -76,6 +76,9 @@ if is_scipy_available():
import
scipy.stats
AnnotationType
=
Dict
[
str
,
Union
[
int
,
str
,
List
[
Dict
]]]
class
AnnotionFormat
(
ExplicitEnum
):
COCO_DETECTION
=
"coco_detection"
COCO_PANOPTIC
=
"coco_panoptic"
...
...
@@ -1037,7 +1040,7 @@ class DetrImageProcessor(BaseImageProcessor):
def
preprocess
(
self
,
images
:
ImageInput
,
annotations
:
Optional
[
Union
[
List
[
Dict
],
List
[
List
[
Dict
]
]]]
=
None
,
annotations
:
Optional
[
Union
[
AnnotationType
,
List
[
AnnotationType
]]]
=
None
,
return_segmentation_masks
:
bool
=
None
,
masks_path
:
Optional
[
Union
[
str
,
pathlib
.
Path
]]
=
None
,
do_resize
:
Optional
[
bool
]
=
None
,
...
...
@@ -1060,7 +1063,7 @@ class DetrImageProcessor(BaseImageProcessor):
Args:
images (`ImageInput`):
Image or batch of images to preprocess.
annotations (`
List[Dict]` or `List[List[Dict]
]`, *optional*):
annotations (`
AnnotationType` or `List[AnnotationType
]`, *optional*):
List of annotations associated with the image or batch of images. If annotionation is for object
detection, the annotations should be a dictionary with the following keys:
- "image_id" (`int`): The image id.
...
...
@@ -1139,7 +1142,7 @@ class DetrImageProcessor(BaseImageProcessor):
raise
ValueError
(
"Image mean and std must be specified if do_normalize is True."
)
images
=
make_list_of_images
(
images
)
if
annotations
is
not
None
and
isinstance
(
annotations
[
0
]
,
dict
):
if
annotations
is
not
None
and
isinstance
(
annotations
,
dict
):
annotations
=
[
annotations
]
if
annotations
is
not
None
and
len
(
images
)
!=
len
(
annotations
):
...
...
src/transformers/models/yolos/image_processing_yolos.py
View file @
59611a0f
...
...
@@ -75,6 +75,9 @@ if is_scipy_available():
import
scipy.stats
AnnotationType
=
Dict
[
str
,
Union
[
int
,
str
,
List
[
Dict
]]]
class
AnnotionFormat
(
ExplicitEnum
):
COCO_DETECTION
=
"coco_detection"
COCO_PANOPTIC
=
"coco_panoptic"
...
...
@@ -937,7 +940,7 @@ class YolosImageProcessor(BaseImageProcessor):
def
preprocess
(
self
,
images
:
ImageInput
,
annotations
:
Optional
[
Union
[
List
[
Dict
],
List
[
List
[
Dict
]
]]]
=
None
,
annotations
:
Optional
[
Union
[
AnnotationType
,
List
[
AnnotationType
]]]
=
None
,
return_segmentation_masks
:
bool
=
None
,
masks_path
:
Optional
[
Union
[
str
,
pathlib
.
Path
]]
=
None
,
do_resize
:
Optional
[
bool
]
=
None
,
...
...
@@ -960,7 +963,7 @@ class YolosImageProcessor(BaseImageProcessor):
Args:
images (`ImageInput`):
Image or batch of images to preprocess.
annotations (`
List[Dict]` or `List[List[Dict]
]`, *optional*):
annotations (`
AnnotationType` or `List[AnnotationType
]`, *optional*):
List of annotations associated with the image or batch of images. If annotionation is for object
detection, the annotations should be a dictionary with the following keys:
- "image_id" (`int`): The image id.
...
...
@@ -1039,7 +1042,7 @@ class YolosImageProcessor(BaseImageProcessor):
raise
ValueError
(
"Image mean and std must be specified if do_normalize is True."
)
images
=
make_list_of_images
(
images
)
if
annotations
is
not
None
and
isinstance
(
annotations
[
0
]
,
dict
):
if
annotations
is
not
None
and
isinstance
(
annotations
,
dict
):
annotations
=
[
annotations
]
if
annotations
is
not
None
and
len
(
images
)
!=
len
(
annotations
):
...
...
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