stevengrove
commited on
Commit
•
de00aaf
1
Parent(s):
53f69b4
Update app.py
Browse files
app.py
CHANGED
@@ -6,4 +6,64 @@ os.system("mim install 'mmcv-lite==2.0.1'")
|
|
6 |
os.system("mim install 'mmdet>=3.0.0,<4.0.0'")
|
7 |
os.system("mim install 'mmyolo'")
|
8 |
os.system("pip install -e .")
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
os.system("mim install 'mmdet>=3.0.0,<4.0.0'")
|
7 |
os.system("mim install 'mmyolo'")
|
8 |
os.system("pip install -e .")
|
9 |
+
|
10 |
+
import argparse
|
11 |
+
import os.path as osp
|
12 |
+
|
13 |
+
from mmengine.config import Config, DictAction
|
14 |
+
from mmengine.runner import Runner
|
15 |
+
from mmengine.dataset import Compose
|
16 |
+
from mmyolo.registry import RUNNERS
|
17 |
+
|
18 |
+
from tools.demo import demo
|
19 |
+
|
20 |
+
|
21 |
+
def parse_args():
|
22 |
+
parser = argparse.ArgumentParser(
|
23 |
+
description='YOLO-World Demo')
|
24 |
+
parser.add_argument('--config', default='configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py')
|
25 |
+
parser.add_argument('--checkpoint', default='yolow-v8_l_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth')
|
26 |
+
parser.add_argument(
|
27 |
+
'--work-dir',
|
28 |
+
help='the directory to save the file containing evaluation metrics')
|
29 |
+
parser.add_argument(
|
30 |
+
'--cfg-options',
|
31 |
+
nargs='+',
|
32 |
+
action=DictAction,
|
33 |
+
help='override some settings in the used config, the key-value pair '
|
34 |
+
'in xxx=yyy format will be merged into config file. If the value to '
|
35 |
+
'be overwritten is a list, it should be like key="[a,b]" or key=a,b '
|
36 |
+
'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" '
|
37 |
+
'Note that the quotation marks are necessary and that no white space '
|
38 |
+
'is allowed.')
|
39 |
+
args = parser.parse_args()
|
40 |
+
return args
|
41 |
+
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
args = parse_args()
|
45 |
+
|
46 |
+
# load config
|
47 |
+
cfg = Config.fromfile(args.config)
|
48 |
+
if args.cfg_options is not None:
|
49 |
+
cfg.merge_from_dict(args.cfg_options)
|
50 |
+
|
51 |
+
if args.work_dir is not None:
|
52 |
+
cfg.work_dir = args.work_dir
|
53 |
+
elif cfg.get('work_dir', None) is None:
|
54 |
+
cfg.work_dir = osp.join('./work_dirs',
|
55 |
+
osp.splitext(osp.basename(args.config))[0])
|
56 |
+
|
57 |
+
cfg.load_from = args.checkpoint
|
58 |
+
|
59 |
+
if 'runner_type' not in cfg:
|
60 |
+
runner = Runner.from_cfg(cfg)
|
61 |
+
else:
|
62 |
+
runner = RUNNERS.build(cfg)
|
63 |
+
|
64 |
+
runner.call_hook('before_run')
|
65 |
+
runner.load_or_resume()
|
66 |
+
pipeline = cfg.test_dataloader.dataset.pipeline
|
67 |
+
runner.pipeline = Compose(pipeline)
|
68 |
+
runner.model.eval()
|
69 |
+
demo(runner, args, cfg)
|