Spaces:
Sleeping
Sleeping
fiber
Browse files
app.py
CHANGED
@@ -42,8 +42,6 @@ from maskrcnn_benchmark.engine.predictor_glip import GLIPDemo
|
|
42 |
config_file = "configs/pretrain_new/desco_glip.yaml"
|
43 |
weight_file = "MODEL/desco_glip_tiny.pth"
|
44 |
|
45 |
-
config_file = "configs/pretrain_new/desco_fiber.yaml"
|
46 |
-
weight_file = "MODEL/desco_fiber_base.pth"
|
47 |
|
48 |
# Use this command if you want to try the GLIP-L model
|
49 |
# ! wget https://penzhanwu2bbs.blob.core.windows.net/data/GLIPv1_Open/models/glip_large_model.pth -O MODEL/glip_large_model.pth
|
@@ -65,6 +63,16 @@ glip_demo = GLIPDemo(
|
|
65 |
show_mask_heatmaps=False
|
66 |
)
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
def predict(image, text, specified_tokens=""):
|
70 |
if specified_tokens.strip() == "":
|
@@ -72,7 +80,8 @@ def predict(image, text, specified_tokens=""):
|
|
72 |
else:
|
73 |
specified_tokens = specified_tokens.strip().split(";")
|
74 |
result, _ = glip_demo.run_on_web_image(image[:, :, [2, 1, 0]], text, 0.5, specified_tokens)
|
75 |
-
|
|
|
76 |
|
77 |
|
78 |
image = gr.inputs.Image()
|
@@ -86,6 +95,10 @@ gr.Interface(
|
|
86 |
type="pil",
|
87 |
# label="grounding results"
|
88 |
),
|
|
|
|
|
|
|
|
|
89 |
],
|
90 |
examples=[
|
91 |
#["./flickr_9472793441.jpg", "bobble heads on top of the shelf ."],
|
|
|
42 |
config_file = "configs/pretrain_new/desco_glip.yaml"
|
43 |
weight_file = "MODEL/desco_glip_tiny.pth"
|
44 |
|
|
|
|
|
45 |
|
46 |
# Use this command if you want to try the GLIP-L model
|
47 |
# ! wget https://penzhanwu2bbs.blob.core.windows.net/data/GLIPv1_Open/models/glip_large_model.pth -O MODEL/glip_large_model.pth
|
|
|
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 |
+
cfg.merge_from_list(["MODEL.WEIGHT", weight_file])
|
69 |
+
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])
|
70 |
+
fiber_demo = GLIPDemo(
|
71 |
+
cfg,
|
72 |
+
min_image_size=800,
|
73 |
+
confidence_threshold=0.7,
|
74 |
+
show_mask_heatmaps=False
|
75 |
+
)
|
76 |
|
77 |
def predict(image, text, specified_tokens=""):
|
78 |
if specified_tokens.strip() == "":
|
|
|
80 |
else:
|
81 |
specified_tokens = specified_tokens.strip().split(";")
|
82 |
result, _ = glip_demo.run_on_web_image(image[:, :, [2, 1, 0]], text, 0.5, specified_tokens)
|
83 |
+
fiber_result, _ = fiber_demo.run_on_web_image(image[:, :, [2, 1, 0]], text, 0.5, specified_tokens)
|
84 |
+
return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]]
|
85 |
|
86 |
|
87 |
image = gr.inputs.Image()
|
|
|
95 |
type="pil",
|
96 |
# label="grounding results"
|
97 |
),
|
98 |
+
gr.outputs.Image(
|
99 |
+
type="pil",
|
100 |
+
# label="grounding results"
|
101 |
+
),
|
102 |
],
|
103 |
examples=[
|
104 |
#["./flickr_9472793441.jpg", "bobble heads on top of the shelf ."],
|