shikunl commited on
Commit
1dd8a60
1 Parent(s): 0312353

Test experts

Browse files
Files changed (2) hide show
  1. app_caption.py +2 -2
  2. prismer_model.py +2 -2
app_caption.py CHANGED
@@ -14,8 +14,8 @@ def create_demo():
14
 
15
  with gr.Row():
16
  with gr.Column():
 
17
  image = gr.Image(label='Input', type='filepath')
18
- model_name = gr.Dropdown(label='Model', choices=['prismer_base'], value='prismer_base')
19
  run_button = gr.Button('Run')
20
  with gr.Column(scale=1.5):
21
  caption = gr.Text(label='Caption')
@@ -40,7 +40,7 @@ def create_demo():
40
  # cache_examples=os.getenv('SYSTEM') == 'spaces')
41
 
42
  paths = sorted(pathlib.Path('prismer/images').glob('*'))
43
- examples = [[path.as_posix(), 'prismer_base'] for path in paths]
44
  gr.Examples(examples=examples,
45
  inputs=inputs,
46
  outputs=outputs,
 
14
 
15
  with gr.Row():
16
  with gr.Column():
17
+ model_name = gr.Dropdown(label='Model', choices=['Prismer-Base'], value='Prismer-Base')
18
  image = gr.Image(label='Input', type='filepath')
 
19
  run_button = gr.Button('Run')
20
  with gr.Column(scale=1.5):
21
  caption = gr.Text(label='Caption')
 
40
  # cache_examples=os.getenv('SYSTEM') == 'spaces')
41
 
42
  paths = sorted(pathlib.Path('prismer/images').glob('*'))
43
+ examples = [[path.as_posix(), 'Prismer-Base'] for path in paths]
44
  gr.Examples(examples=examples,
45
  inputs=inputs,
46
  outputs=outputs,
prismer_model.py CHANGED
@@ -53,7 +53,7 @@ def run_experts(image_path: str) -> tuple[str | None, ...]:
53
  env['PYTHONPATH'] = f'{submodule_dir.as_posix()}:{env["PYTHONPATH"]}'
54
  else:
55
  env['PYTHONPATH'] = submodule_dir.as_posix()
56
- subprocess.run(shlex.split(f'python experts/generate_{expert_name}.py'), cwd='prismer', env=env, check=True)
57
 
58
  keys = ['depth', 'edge', 'normal', 'seg_coco', 'obj_detection', 'ocr_detection']
59
  results = [pathlib.Path('prismer/helpers/labels') / key / 'helpers/images/image.png' for key in keys]
@@ -77,7 +77,7 @@ class Model:
77
  'label_path': 'prismer/helpers/labels',
78
  'experts': ['depth', 'normal', 'seg_coco', 'edge', 'obj_detection', 'ocr_detection'],
79
  'image_resolution': 480,
80
- 'prismer_model': 'prismer_base',
81
  'freeze': 'freeze_vision',
82
  'prefix': 'A picture of',
83
  }
 
53
  env['PYTHONPATH'] = f'{submodule_dir.as_posix()}:{env["PYTHONPATH"]}'
54
  else:
55
  env['PYTHONPATH'] = submodule_dir.as_posix()
56
+ subprocess.run(shlex.split(f'accelerate experts/generate_{expert_name}.py'), cwd='prismer', env=env, check=True)
57
 
58
  keys = ['depth', 'edge', 'normal', 'seg_coco', 'obj_detection', 'ocr_detection']
59
  results = [pathlib.Path('prismer/helpers/labels') / key / 'helpers/images/image.png' for key in keys]
 
77
  'label_path': 'prismer/helpers/labels',
78
  'experts': ['depth', 'normal', 'seg_coco', 'edge', 'obj_detection', 'ocr_detection'],
79
  'image_resolution': 480,
80
+ 'prismer_model': 'prismer_base' if self.exp_name == 'Prismer-Base' else 'prismer_large',
81
  'freeze': 'freeze_vision',
82
  'prefix': 'A picture of',
83
  }