Spaces:
Sleeping
Sleeping
Fix path
Browse files
prismer/experts/generate_depth.py
CHANGED
@@ -20,7 +20,7 @@ from tqdm import tqdm
|
|
20 |
model, transform = load_expert_model(task='depth')
|
21 |
accelerator = Accelerator(mixed_precision='fp16')
|
22 |
|
23 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
24 |
data_path = config['data_path']
|
25 |
save_path = os.path.join(config['save_path'], 'depth')
|
26 |
|
|
|
20 |
model, transform = load_expert_model(task='depth')
|
21 |
accelerator = Accelerator(mixed_precision='fp16')
|
22 |
|
23 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
24 |
data_path = config['data_path']
|
25 |
save_path = os.path.join(config['save_path'], 'depth')
|
26 |
|
prismer/experts/generate_edge.py
CHANGED
@@ -22,7 +22,7 @@ from tqdm import tqdm
|
|
22 |
model, transform = load_expert_model(task='edge')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = os.path.join(config['save_path'], 'edge')
|
28 |
|
|
|
22 |
model, transform = load_expert_model(task='edge')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = os.path.join(config['save_path'], 'edge')
|
28 |
|
prismer/experts/generate_normal.py
CHANGED
@@ -22,7 +22,7 @@ import numpy as np
|
|
22 |
model, transform = load_expert_model(task='normal')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = os.path.join(config['save_path'], 'normal')
|
28 |
|
|
|
22 |
model, transform = load_expert_model(task='normal')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = os.path.join(config['save_path'], 'normal')
|
28 |
|
prismer/experts/generate_objdet.py
CHANGED
@@ -22,7 +22,7 @@ from tqdm import tqdm
|
|
22 |
model, transform = load_expert_model(task='obj_detection')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = config['save_path']
|
28 |
|
|
|
22 |
model, transform = load_expert_model(task='obj_detection')
|
23 |
accelerator = Accelerator(mixed_precision='fp16')
|
24 |
|
25 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
26 |
data_path = config['data_path']
|
27 |
save_path = config['save_path']
|
28 |
|
prismer/experts/generate_ocrdet.py
CHANGED
@@ -26,7 +26,7 @@ model, transform = load_expert_model(task='ocr_detection')
|
|
26 |
accelerator = Accelerator(mixed_precision='fp16')
|
27 |
pca_clip = pk.load(open('dataset/clip_pca.pkl', 'rb'))
|
28 |
|
29 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
30 |
data_path = config['data_path']
|
31 |
save_path = os.path.join(config['save_path'], 'ocr_detection')
|
32 |
|
|
|
26 |
accelerator = Accelerator(mixed_precision='fp16')
|
27 |
pca_clip = pk.load(open('dataset/clip_pca.pkl', 'rb'))
|
28 |
|
29 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
30 |
data_path = config['data_path']
|
31 |
save_path = os.path.join(config['save_path'], 'ocr_detection')
|
32 |
|
prismer/experts/generate_segmentation.py
CHANGED
@@ -20,7 +20,7 @@ from tqdm import tqdm
|
|
20 |
model, transform = load_expert_model(task='seg_coco')
|
21 |
accelerator = Accelerator(mixed_precision='fp16')
|
22 |
|
23 |
-
config = yaml.load(open('configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
24 |
data_path = config['data_path']
|
25 |
save_path = os.path.join(config['save_path'], 'seg_coco')
|
26 |
|
|
|
20 |
model, transform = load_expert_model(task='seg_coco')
|
21 |
accelerator = Accelerator(mixed_precision='fp16')
|
22 |
|
23 |
+
config = yaml.load(open('prismer/configs/experts.yaml', 'r'), Loader=yaml.Loader)
|
24 |
data_path = config['data_path']
|
25 |
save_path = os.path.join(config['save_path'], 'seg_coco')
|
26 |
|
prismer_model.py
CHANGED
@@ -53,19 +53,11 @@ 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(
|
57 |
-
shlex.split(f'python experts/generate_{expert_name}.py'),
|
58 |
-
cwd='prismer',
|
59 |
-
env=env,
|
60 |
-
check=True)
|
61 |
|
62 |
keys = ['depth', 'edge', 'normal', 'seg_coco', 'obj_detection', 'ocr_detection']
|
63 |
-
results = [
|
64 |
-
|
65 |
-
'helpers/images/image.png' for key in keys
|
66 |
-
]
|
67 |
-
return tuple(path.as_posix() if path.exists() else None
|
68 |
-
for path in results)
|
69 |
|
70 |
|
71 |
class Model:
|
@@ -116,5 +108,5 @@ class Model:
|
|
116 |
|
117 |
def run_caption(self, image_path: str, model_name: str) -> tuple[str | None, ...]:
|
118 |
out_paths = run_experts(image_path)
|
119 |
-
caption = self.run_caption_model(model_name)
|
120 |
-
return
|
|
|
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]
|
60 |
+
return tuple(path.as_posix() if path.exists() else None for path in results)
|
|
|
|
|
|
|
|
|
61 |
|
62 |
|
63 |
class Model:
|
|
|
108 |
|
109 |
def run_caption(self, image_path: str, model_name: str) -> tuple[str | None, ...]:
|
110 |
out_paths = run_experts(image_path)
|
111 |
+
# caption = self.run_caption_model(model_name)
|
112 |
+
return None, *out_paths
|