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