Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify yolox and model load #339

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions easycv/models/detection/detectors/yolox/yolox.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def __init__(self,

assert model_type in self.param_map, f'invalid model_type for yolox {model_type}, valid ones are {list(self.param_map.keys())}'

if num_classes is not None:
# adapt to previous export model (before easycv0.6.0)
logging.warning(
'Warning: You are now attend to use an old YOLOX model before easycv0.6.0 with key num_classes'
)
head = dict(
type='YOLOXHead',
model_type=model_type,
num_classes=num_classes,
)

# the change of backbone/neck/head only support model_type as 's'
if model_type != 's':
head_type = head.get('type', None)
assert backbone == 'CSPDarknet' and neck_type == 'yolo' and neck_mode == 'all' and head_type == 'YOLOXHead', 'We only support the architecture modification for YOLOX-S.'

self.pretrained = pretrained

in_channels = [256, 512, 1024]
Expand All @@ -68,19 +84,14 @@ def __init__(self,
asff_channel=asff_channel,
use_att=use_att)

if num_classes is not None:
# adapt to previous export model (before easycv0.6.0)
logging.warning(
'Warning: You are now attend to use an old YOLOX model before easycv0.6.0 with key num_classes'
)
head = dict(
type='YOLOXHead',
model_type=model_type,
num_classes=num_classes,
)

if head is not None:
# head is None for YOLOX-edge to define a special head
# set and check model type in head as the same of yolox
head_model_type = head.get('model_type', None)
if head_model_type is None:
head['model_type'] = model_type
else:
assert model_type == head_model_type, 'Please provide the same model_type of YOLOX in config.'
self.head = build_head(head)
self.num_classes = self.head.num_classes

Expand Down
Loading