shikunl commited on
Commit
a8797f1
β€’
1 Parent(s): 3cce9aa
Files changed (1) hide show
  1. prismer_model.py +7 -7
prismer_model.py CHANGED
@@ -7,12 +7,12 @@ import sys
7
  import cv2
8
  import torch
9
 
10
- from prismer.dataset import create_dataset, create_loader
11
- from prismer.model.prismer_caption import PrismerCaption
12
-
13
-
14
  repo_dir = pathlib.Path(__file__).parent
15
  submodule_dir = repo_dir / 'prismer'
 
 
 
 
16
 
17
 
18
  def download_models() -> None:
@@ -50,11 +50,11 @@ def run_experts(image_path: str) -> tuple[str | None, ...]:
50
  for expert_name in expert_names:
51
  env = os.environ.copy()
52
  if 'PYTHONPATH' in env:
53
- env['PYTHONPATH'] = f'{repo_dir.as_posix()}:{env["PYTHONPATH"]}'
54
  else:
55
- env['PYTHONPATH'] = repo_dir.as_posix()
56
 
57
- subprocess.run(shlex.split(f'python prismer/experts/generate_{expert_name}.py'), env=env, check=True)
58
 
59
  # keys = ['depth', 'edge', 'normal', 'seg_coco', 'obj_detection', 'ocr_detection']
60
  keys = ['depth', 'edge', 'normal']
 
7
  import cv2
8
  import torch
9
 
 
 
 
 
10
  repo_dir = pathlib.Path(__file__).parent
11
  submodule_dir = repo_dir / 'prismer'
12
+ sys.path.insert(0, submodule_dir.as_posix())
13
+
14
+ from dataset import create_dataset, create_loader
15
+ from model.prismer_caption import PrismerCaption
16
 
17
 
18
  def download_models() -> None:
 
50
  for expert_name in expert_names:
51
  env = os.environ.copy()
52
  if 'PYTHONPATH' in env:
53
+ env['PYTHONPATH'] = f'{submodule_dir.as_posix()}:{env["PYTHONPATH"]}'
54
  else:
55
+ env['PYTHONPATH'] = submodule_dir.as_posix()
56
 
57
+ subprocess.run(shlex.split(f'python experts/generate_{expert_name}.py'), cwd='prismer', env=env, check=True)
58
 
59
  # keys = ['depth', 'edge', 'normal', 'seg_coco', 'obj_detection', 'ocr_detection']
60
  keys = ['depth', 'edge', 'normal']