Spaces:
Runtime error
Runtime error
Nadine Rueegg
commited on
Commit
·
7c170d0
1
Parent(s):
6276e10
allow caching
Browse files- scripts/gradio_demo.py +9 -4
scripts/gradio_demo.py
CHANGED
@@ -239,7 +239,7 @@ if not os.path.exists(save_imgs_path):
|
|
239 |
|
240 |
|
241 |
|
242 |
-
def run_bite_inference(input_image, bbox=None, apply_ttopt=True):
|
243 |
|
244 |
with open(loss_weight_path, 'r') as j:
|
245 |
losses = json.loads(j.read())
|
@@ -540,7 +540,7 @@ def run_bite_inference(input_image, bbox=None, apply_ttopt=True):
|
|
540 |
[0, -1, 0, 0],
|
541 |
[0, 0, 1, 1],
|
542 |
[0, 0, 0, 1]])
|
543 |
-
result_path = os.path.join(save_imgs_path,
|
544 |
mesh.export(file_obj=result_path + '.glb')
|
545 |
result_gltf = result_path + '.glb'
|
546 |
return result_gltf
|
@@ -574,7 +574,12 @@ def run_complete_inference(img_path_or_img, crop_choice, use_ttopt):
|
|
574 |
else:
|
575 |
apply_ttopt = False
|
576 |
# run barc inference
|
577 |
-
|
|
|
|
|
|
|
|
|
|
|
578 |
# add white border to image for nicer alignment
|
579 |
output_interm_image_vis = np.concatenate((255*np.ones_like(output_interm_image), output_interm_image, 255*np.ones_like(output_interm_image)), axis=1)
|
580 |
return [result_gltf, result_gltf, output_interm_image_vis]
|
@@ -659,7 +664,7 @@ demo = gr.Interface(
|
|
659 |
examples=examples,
|
660 |
thumbnail="bite_thumbnail.png",
|
661 |
allow_flagging="never",
|
662 |
-
cache_examples=
|
663 |
examples_per_page=14,
|
664 |
)
|
665 |
|
|
|
239 |
|
240 |
|
241 |
|
242 |
+
def run_bite_inference(input_image, bbox=None, apply_ttopt=True, dog_name="dog_model"):
|
243 |
|
244 |
with open(loss_weight_path, 'r') as j:
|
245 |
losses = json.loads(j.read())
|
|
|
540 |
[0, -1, 0, 0],
|
541 |
[0, 0, 1, 1],
|
542 |
[0, 0, 0, 1]])
|
543 |
+
result_path = os.path.join(save_imgs_path, dog_name)
|
544 |
mesh.export(file_obj=result_path + '.glb')
|
545 |
result_gltf = result_path + '.glb'
|
546 |
return result_gltf
|
|
|
574 |
else:
|
575 |
apply_ttopt = False
|
576 |
# run barc inference
|
577 |
+
if img_path_or_img.dtype == str:
|
578 |
+
dog_name = os.path.basename(img_path_or_img).split(".")[0]
|
579 |
+
else:
|
580 |
+
dog_name = "dog"
|
581 |
+
|
582 |
+
result_gltf = run_bite_inference(img_path_or_img, output_interm_bbox, apply_ttopt, dog_name=dog_name)
|
583 |
# add white border to image for nicer alignment
|
584 |
output_interm_image_vis = np.concatenate((255*np.ones_like(output_interm_image), output_interm_image, 255*np.ones_like(output_interm_image)), axis=1)
|
585 |
return [result_gltf, result_gltf, output_interm_image_vis]
|
|
|
664 |
examples=examples,
|
665 |
thumbnail="bite_thumbnail.png",
|
666 |
allow_flagging="never",
|
667 |
+
cache_examples=True,
|
668 |
examples_per_page=14,
|
669 |
)
|
670 |
|