zdou0830 commited on
Commit
e62892f
1 Parent(s): b39562c

local test

Browse files
Files changed (3) hide show
  1. MODEL/local1.pth +3 -0
  2. MODEL/local2.pth +3 -0
  3. app.py +39 -1
MODEL/local1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc1399cf65504852e03586a1d665f0613c33baff7228d06c1c061a30961174ab
3
+ size 3709941017
MODEL/local2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b696e97ef9e82ae5e080f51ea0e50134d78e2cfd336b8d75590ee9b53d9f2f51
3
+ size 3709919257
app.py CHANGED
@@ -49,6 +49,34 @@ fiber_demo = GLIPDemo(
49
  show_mask_heatmaps=False
50
  )
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  athetics_params = {
53
  "skip_name": False, # whether we overlay the phrase over the box
54
  "override_color": (0, 90, 190),
@@ -67,7 +95,9 @@ def predict(image, text, ground_tokens=""):
67
  ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
68
  result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
69
  fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
70
- return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]]
 
 
71
 
72
 
73
  image = gr.inputs.Image()
@@ -87,6 +117,14 @@ gr.Interface(
87
  type="pil",
88
  label="DesCo-FIBER"
89
  ),
 
 
 
 
 
 
 
 
90
  ],
91
  examples=[
92
  ["./1.jpg", "A clown making a balloon animal for a pretty lady.", "clown"],
 
49
  show_mask_heatmaps=False
50
  )
51
 
52
+ config_file = "configs/pretrain_new/desco_glip.yaml"
53
+ weight_file = "MODEL/local1.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_demo1 = 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_glip.yaml"
67
+ weight_file = "MODEL/local2.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
+ local_demo2 = GLIPDemo(
74
+ cfg,
75
+ min_image_size=800,
76
+ confidence_threshold=0.7,
77
+ show_mask_heatmaps=False
78
+ )
79
+
80
  athetics_params = {
81
  "skip_name": False, # whether we overlay the phrase over the box
82
  "override_color": (0, 90, 190),
 
95
  ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
96
  result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
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()
 
117
  type="pil",
118
  label="DesCo-FIBER"
119
  ),
120
+ gr.outputs.Image(
121
+ type="pil",
122
+ label="local1"
123
+ ),
124
+ gr.outputs.Image(
125
+ type="pil",
126
+ label="local2"
127
+ ),
128
  ],
129
  examples=[
130
  ["./1.jpg", "A clown making a balloon animal for a pretty lady.", "clown"],