Skip to content

[cherry-pick] fix unittest #7807

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

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions configs/datasets/voc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ map_type: 11point
num_classes: 20

TrainDataset:
!VOCDataSet
dataset_dir: dataset/voc
anno_path: trainval.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']
name: VOCDataSet
dataset_dir: dataset/voc
anno_path: trainval.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']

EvalDataset:
!VOCDataSet
dataset_dir: dataset/voc
anno_path: test.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']
name: VOCDataSet
dataset_dir: dataset/voc
anno_path: test.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']

TestDataset:
!ImageFolder
anno_path: dataset/voc/label_list.txt
name: ImageFolder
anno_path: dataset/voc/label_list.txt
1 change: 1 addition & 0 deletions configs/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use_gpu: true
use_xpu: false
use_mlu: false
use_npu: false
log_iter: 20
save_dir: output
snapshot_epoch: 1
Expand Down
11 changes: 10 additions & 1 deletion ppdet/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ def __getattr__(self, key):
return self[key]
raise AttributeError("object has no attribute '{}'".format(key))

def __setattr__(self, key, value):
self[key] = value

def copy(self):
new_dict = AttrDict()
for k, v in self.items():
new_dict.update({k: v})
return new_dict


global_config = AttrDict()

Expand Down Expand Up @@ -280,4 +289,4 @@ def create(cls_or_name, **kwargs):
# prevent modification of global config values of reference types
# (e.g., list, dict) from within the created module instances
#kwargs = copy.deepcopy(kwargs)
return cls(**cls_kwargs)
return cls(**cls_kwargs)
8 changes: 4 additions & 4 deletions ppdet/engine/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

class Trainer(object):
def __init__(self, cfg, mode='train'):
self.cfg = cfg
self.cfg = cfg.copy()
assert mode.lower() in ['train', 'eval', 'test'], \
"mode should be 'train', 'eval' or 'test'"
self.mode = mode.lower()
Expand Down Expand Up @@ -99,12 +99,12 @@ def __init__(self, cfg, mode='train'):
self.dataset, cfg.worker_num)

if cfg.architecture == 'JDE' and self.mode == 'train':
cfg['JDEEmbeddingHead'][
self.cfg['JDEEmbeddingHead'][
'num_identities'] = self.dataset.num_identities_dict[0]
# JDE only support single class MOT now.

if cfg.architecture == 'FairMOT' and self.mode == 'train':
cfg['FairMOTEmbeddingHead'][
self.cfg['FairMOTEmbeddingHead'][
'num_identities_dict'] = self.dataset.num_identities_dict
# FairMOT support single class and multi-class MOT now.

Expand Down Expand Up @@ -149,7 +149,7 @@ def __init__(self, cfg, mode='train'):
reader_name = '{}Reader'.format(self.mode.capitalize())
# If metric is VOC, need to be set collate_batch=False.
if cfg.metric == 'VOC':
cfg[reader_name]['collate_batch'] = False
self.cfg[reader_name]['collate_batch'] = False
self.loader = create(reader_name)(self.dataset, cfg.worker_num,
self._eval_batch_sampler)
# TestDataset build after user set images, skip loader creation here
Expand Down