Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -150,7 +150,7 @@ def build_model_and_transforms(args):
|
|
150 |
build_func = MODULE_BUILD_FUNCS.get(args.modelname)
|
151 |
model, _, _ = build_func(args)
|
152 |
|
153 |
-
model.to(device)
|
154 |
|
155 |
checkpoint = torch.load(args.pretrain_model_path, map_location="cpu")["model"]
|
156 |
model.load_state_dict(checkpoint, strict=False)
|
@@ -223,6 +223,7 @@ def get_ind_to_filter(text, word_ids, keywords):
|
|
223 |
|
224 |
@spaces.GPU
|
225 |
def count(image, text, prompts, state, device):
|
|
|
226 |
print("state: " + str(state))
|
227 |
keywords = "" # do not handle this for now
|
228 |
# Handle no prompt case.
|
@@ -308,10 +309,12 @@ def count(image, text, prompts, state, device):
|
|
308 |
out_label += " " + str(exemplars[0].size()[0]) + " visual exemplars."
|
309 |
else:
|
310 |
out_label = "Nothing specified to detect."
|
|
|
311 |
return (gr.Image(output_img, visible=True, label=out_label, show_label=True), gr.Number(label="Predicted Count", visible=True, value=boxes.shape[0]), new_submit_btn, gr.Tab(visible=True), step_3, state)
|
312 |
|
313 |
@spaces.GPU
|
314 |
def count_main(image, text, prompts, device):
|
|
|
315 |
keywords = "" # do not handle this for now
|
316 |
# Handle no prompt case.
|
317 |
if prompts is None:
|
@@ -378,6 +381,7 @@ def count_main(image, text, prompts, device):
|
|
378 |
out_label += " " + str(exemplars[0].size()[0]) + " visual exemplars."
|
379 |
else:
|
380 |
out_label = "Nothing specified to detect."
|
|
|
381 |
return (gr.Image(output_img, visible=True, label=out_label, show_label=True), gr.Number(label="Predicted Count", visible=True, value=boxes.shape[0]))
|
382 |
|
383 |
def remove_label(image):
|
|
|
150 |
build_func = MODULE_BUILD_FUNCS.get(args.modelname)
|
151 |
model, _, _ = build_func(args)
|
152 |
|
153 |
+
#model.to(device)
|
154 |
|
155 |
checkpoint = torch.load(args.pretrain_model_path, map_location="cpu")["model"]
|
156 |
model.load_state_dict(checkpoint, strict=False)
|
|
|
223 |
|
224 |
@spaces.GPU
|
225 |
def count(image, text, prompts, state, device):
|
226 |
+
model.to(device)
|
227 |
print("state: " + str(state))
|
228 |
keywords = "" # do not handle this for now
|
229 |
# Handle no prompt case.
|
|
|
309 |
out_label += " " + str(exemplars[0].size()[0]) + " visual exemplars."
|
310 |
else:
|
311 |
out_label = "Nothing specified to detect."
|
312 |
+
model.cpu()
|
313 |
return (gr.Image(output_img, visible=True, label=out_label, show_label=True), gr.Number(label="Predicted Count", visible=True, value=boxes.shape[0]), new_submit_btn, gr.Tab(visible=True), step_3, state)
|
314 |
|
315 |
@spaces.GPU
|
316 |
def count_main(image, text, prompts, device):
|
317 |
+
model.to(device)
|
318 |
keywords = "" # do not handle this for now
|
319 |
# Handle no prompt case.
|
320 |
if prompts is None:
|
|
|
381 |
out_label += " " + str(exemplars[0].size()[0]) + " visual exemplars."
|
382 |
else:
|
383 |
out_label = "Nothing specified to detect."
|
384 |
+
model.cpu()
|
385 |
return (gr.Image(output_img, visible=True, label=out_label, show_label=True), gr.Number(label="Predicted Count", visible=True, value=boxes.shape[0]))
|
386 |
|
387 |
def remove_label(image):
|