Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteca61d3

Browse files
authored
tools/analysis_tools browse_dataset.py (#2649)
## Motivationbrowse_dataset before training## Modificationcreate tools/analysis_tools/browse_dataset.py
1 parent619a3c2 commiteca61d3

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
importargparse
3+
importos.pathasosp
4+
5+
frommmengine.configimportConfig,DictAction
6+
frommmengine.utilsimportProgressBar
7+
8+
frommmseg.registryimportDATASETS,VISUALIZERS
9+
frommmseg.utilsimportregister_all_modules
10+
11+
12+
defparse_args():
13+
parser=argparse.ArgumentParser(description='Browse a dataset')
14+
parser.add_argument('config',help='train config file path')
15+
parser.add_argument(
16+
'--output-dir',
17+
default=None,
18+
type=str,
19+
help='If there is no display interface, you can save it')
20+
parser.add_argument('--not-show',default=False,action='store_true')
21+
parser.add_argument(
22+
'--show-interval',
23+
type=float,
24+
default=2,
25+
help='the interval of show (s)')
26+
parser.add_argument(
27+
'--cfg-options',
28+
nargs='+',
29+
action=DictAction,
30+
help='override some settings in the used config, the key-value pair '
31+
'in xxx=yyy format will be merged into config file. If the value to '
32+
'be overwritten is a list, it should be like key="[a,b]" or key=a,b '
33+
'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" '
34+
'Note that the quotation marks are necessary and that no white space '
35+
'is allowed.')
36+
args=parser.parse_args()
37+
returnargs
38+
39+
40+
defmain():
41+
args=parse_args()
42+
cfg=Config.fromfile(args.config)
43+
ifargs.cfg_optionsisnotNone:
44+
cfg.merge_from_dict(args.cfg_options)
45+
46+
# register all modules in mmdet into the registries
47+
register_all_modules()
48+
49+
dataset=DATASETS.build(cfg.train_dataloader.dataset)
50+
visualizer=VISUALIZERS.build(cfg.visualizer)
51+
visualizer.dataset_meta=dataset.metainfo
52+
53+
progress_bar=ProgressBar(len(dataset))
54+
foritemindataset:
55+
img=item['inputs'].permute(1,2,0).numpy()
56+
img=img[..., [2,1,0]]# bgr to rgb
57+
data_sample=item['data_samples'].numpy()
58+
img_path=osp.basename(item['data_samples'].img_path)
59+
60+
out_file=osp.join(
61+
args.output_dir,
62+
osp.basename(img_path))ifargs.output_dirisnotNoneelseNone
63+
64+
visualizer.add_datasample(
65+
name=osp.basename(img_path),
66+
image=img,
67+
data_sample=data_sample,
68+
draw_gt=True,
69+
draw_pred=False,
70+
wait_time=args.show_interval,
71+
out_file=out_file,
72+
show=notargs.not_show)
73+
progress_bar.update()
74+
75+
76+
if__name__=='__main__':
77+
main()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp