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
1a585c12
Unverified
Commit
1a585c12
authored
Dec 14, 2023
by
amyeroberts
Committed by
GitHub
Dec 14, 2023
Browse files
Remove warning when Annotion enum is created (#28048)
Remove warning when enum is created
parent
3060899b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
19 deletions
+11
-19
src/transformers/image_utils.py
src/transformers/image_utils.py
+11
-14
src/transformers/models/conditional_detr/image_processing_conditional_detr.py
...els/conditional_detr/image_processing_conditional_detr.py
+0
-1
src/transformers/models/deformable_detr/image_processing_deformable_detr.py
...odels/deformable_detr/image_processing_deformable_detr.py
+0
-1
src/transformers/models/deta/image_processing_deta.py
src/transformers/models/deta/image_processing_deta.py
+0
-1
src/transformers/models/detr/image_processing_detr.py
src/transformers/models/detr/image_processing_detr.py
+0
-1
src/transformers/models/yolos/image_processing_yolos.py
src/transformers/models/yolos/image_processing_yolos.py
+0
-1
No files found.
src/transformers/image_utils.py
View file @
1a585c12
...
...
@@ -15,7 +15,6 @@
import
base64
import
os
from
enum
import
EnumMeta
from
io
import
BytesIO
from
typing
import
TYPE_CHECKING
,
Dict
,
Iterable
,
List
,
Optional
,
Tuple
,
Union
...
...
@@ -76,16 +75,7 @@ class AnnotationFormat(ExplicitEnum):
COCO_PANOPTIC
=
"coco_panoptic"
class
DeprecatedEnumMeta
(
EnumMeta
):
def
__init__
(
cls
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
logger
.
warning_once
(
f
"`
{
cls
.
__name__
}
` is deprecated and will be removed in v4.38. "
f
"Please use `transformers.image_utils.AnnotationFormat` instead."
)
class
AnnotionFormat
(
ExplicitEnum
,
metaclass
=
DeprecatedEnumMeta
):
class
AnnotionFormat
(
ExplicitEnum
):
COCO_DETECTION
=
AnnotationFormat
.
COCO_DETECTION
.
value
COCO_PANOPTIC
=
AnnotationFormat
.
COCO_PANOPTIC
.
value
...
...
@@ -703,10 +693,17 @@ def validate_annotations(
supported_annotation_formats
:
Tuple
[
AnnotationFormat
,
...],
annotations
:
List
[
Dict
],
)
->
None
:
if
promote_annotation_format
(
annotation_format
)
not
in
supported_annotation_formats
:
if
isinstance
(
annotation_format
,
AnnotionFormat
):
logger
.
warning_once
(
f
"`
{
annotation_format
.
__class__
.
__name__
}
` is deprecated and will be removed in v4.38. "
f
"Please use `
{
AnnotationFormat
.
__name__
}
` instead."
)
annotation_format
=
promote_annotation_format
(
annotation_format
)
if
annotation_format
not
in
supported_annotation_formats
:
raise
ValueError
(
f
"Unsupported annotation format:
{
format
}
must be one of
{
supported_annotation_formats
}
"
)
if
promote_
annotation_format
(
annotation_format
)
is
AnnotationFormat
.
COCO_DETECTION
:
if
annotation_format
is
AnnotationFormat
.
COCO_DETECTION
:
if
not
valid_coco_detection_annotations
(
annotations
):
raise
ValueError
(
"Invalid COCO detection annotations. Annotations must a dict (single image) or list of dicts "
...
...
@@ -714,7 +711,7 @@ def validate_annotations(
"being a list of annotations in the COCO format."
)
if
promote_
annotation_format
(
annotation_format
)
is
AnnotationFormat
.
COCO_PANOPTIC
:
if
annotation_format
is
AnnotationFormat
.
COCO_PANOPTIC
:
if
not
valid_coco_panoptic_annotations
(
annotations
):
raise
ValueError
(
"Invalid COCO panoptic annotations. Annotations must a dict (single image) or list of dicts "
...
...
src/transformers/models/conditional_detr/image_processing_conditional_detr.py
View file @
1a585c12
...
...
@@ -39,7 +39,6 @@ from ...image_utils import (
IMAGENET_DEFAULT_STD
,
AnnotationFormat
,
AnnotationType
,
AnnotionFormat
,
# noqa: F401
ChannelDimension
,
ImageInput
,
PILImageResampling
,
...
...
src/transformers/models/deformable_detr/image_processing_deformable_detr.py
View file @
1a585c12
...
...
@@ -39,7 +39,6 @@ from ...image_utils import (
IMAGENET_DEFAULT_STD
,
AnnotationFormat
,
AnnotationType
,
AnnotionFormat
,
# noqa: F401
ChannelDimension
,
ImageInput
,
PILImageResampling
,
...
...
src/transformers/models/deta/image_processing_deta.py
View file @
1a585c12
...
...
@@ -35,7 +35,6 @@ from ...image_utils import (
IMAGENET_DEFAULT_MEAN
,
IMAGENET_DEFAULT_STD
,
AnnotationFormat
,
AnnotionFormat
,
# noqa: F401
ChannelDimension
,
ImageInput
,
PILImageResampling
,
...
...
src/transformers/models/detr/image_processing_detr.py
View file @
1a585c12
...
...
@@ -38,7 +38,6 @@ from ...image_utils import (
IMAGENET_DEFAULT_STD
,
AnnotationFormat
,
AnnotationType
,
AnnotionFormat
,
# noqa: F401
ChannelDimension
,
ImageInput
,
PILImageResampling
,
...
...
src/transformers/models/yolos/image_processing_yolos.py
View file @
1a585c12
...
...
@@ -37,7 +37,6 @@ from ...image_utils import (
IMAGENET_DEFAULT_STD
,
AnnotationFormat
,
AnnotationType
,
AnnotionFormat
,
# noqa: F401
ChannelDimension
,
ImageInput
,
PILImageResampling
,
...
...
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