Spaces:
Runtime error
Runtime error
local test
Browse files
app.py
CHANGED
|
@@ -35,14 +35,14 @@ glip_demo = GLIPDemo(
|
|
| 35 |
show_mask_heatmaps=False
|
| 36 |
)
|
| 37 |
|
| 38 |
-
config_file = "configs/pretrain_new/
|
| 39 |
-
weight_file = "MODEL/
|
| 40 |
from copy import deepcopy
|
| 41 |
cfg = deepcopy(cfg)
|
| 42 |
cfg.merge_from_file(config_file)
|
| 43 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 44 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 45 |
-
|
| 46 |
cfg,
|
| 47 |
min_image_size=800,
|
| 48 |
confidence_threshold=0.7,
|
|
@@ -50,27 +50,27 @@ fiber_demo = GLIPDemo(
|
|
| 50 |
)
|
| 51 |
|
| 52 |
config_file = "configs/pretrain_new/desco_glip.yaml"
|
| 53 |
-
weight_file = "MODEL/
|
| 54 |
from copy import deepcopy
|
| 55 |
cfg = deepcopy(cfg)
|
| 56 |
cfg.merge_from_file(config_file)
|
| 57 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 58 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 59 |
-
|
| 60 |
cfg,
|
| 61 |
min_image_size=800,
|
| 62 |
confidence_threshold=0.7,
|
| 63 |
show_mask_heatmaps=False
|
| 64 |
)
|
| 65 |
|
| 66 |
-
config_file = "configs/pretrain_new/
|
| 67 |
-
weight_file = "MODEL/
|
| 68 |
from copy import deepcopy
|
| 69 |
cfg = deepcopy(cfg)
|
| 70 |
cfg.merge_from_file(config_file)
|
| 71 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 72 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 73 |
-
|
| 74 |
cfg,
|
| 75 |
min_image_size=800,
|
| 76 |
confidence_threshold=0.7,
|
|
@@ -97,7 +97,7 @@ def predict(image, text, ground_tokens=""):
|
|
| 97 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 98 |
local_result1, _ = local_demo1.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 99 |
local_result2, _ = local_demo2.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 100 |
-
return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]], local_result1, local_result2
|
| 101 |
|
| 102 |
|
| 103 |
image = gr.inputs.Image()
|
|
|
|
| 35 |
show_mask_heatmaps=False
|
| 36 |
)
|
| 37 |
|
| 38 |
+
config_file = "configs/pretrain_new/desco_glip.yaml"
|
| 39 |
+
weight_file = "MODEL/local1.pth"
|
| 40 |
from copy import deepcopy
|
| 41 |
cfg = deepcopy(cfg)
|
| 42 |
cfg.merge_from_file(config_file)
|
| 43 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 44 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 45 |
+
local_demo1 = GLIPDemo(
|
| 46 |
cfg,
|
| 47 |
min_image_size=800,
|
| 48 |
confidence_threshold=0.7,
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
config_file = "configs/pretrain_new/desco_glip.yaml"
|
| 53 |
+
weight_file = "MODEL/local2.pth"
|
| 54 |
from copy import deepcopy
|
| 55 |
cfg = deepcopy(cfg)
|
| 56 |
cfg.merge_from_file(config_file)
|
| 57 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 58 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 59 |
+
local_demo2 = GLIPDemo(
|
| 60 |
cfg,
|
| 61 |
min_image_size=800,
|
| 62 |
confidence_threshold=0.7,
|
| 63 |
show_mask_heatmaps=False
|
| 64 |
)
|
| 65 |
|
| 66 |
+
config_file = "configs/pretrain_new/desco_fiber.yaml"
|
| 67 |
+
weight_file = "MODEL/desco_fiber_base.pth"
|
| 68 |
from copy import deepcopy
|
| 69 |
cfg = deepcopy(cfg)
|
| 70 |
cfg.merge_from_file(config_file)
|
| 71 |
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
| 72 |
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
| 73 |
+
fiber_demo = GLIPDemo(
|
| 74 |
cfg,
|
| 75 |
min_image_size=800,
|
| 76 |
confidence_threshold=0.7,
|
|
|
|
| 97 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 98 |
local_result1, _ = local_demo1.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 99 |
local_result2, _ = local_demo2.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
| 100 |
+
return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]], local_result1[:, :, [2, 1, 0]], local_result2[:, :, [2, 1, 0]]
|
| 101 |
|
| 102 |
|
| 103 |
image = gr.inputs.Image()
|