Spaces:
Sleeping
Sleeping
Enabled ZeroGPU
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import copy
|
3 |
import random
|
@@ -92,6 +93,7 @@ def get_args_parser():
|
|
92 |
parser.add_argument("--amp", action="store_true", help="Train with mixed precision")
|
93 |
return parser
|
94 |
|
|
|
95 |
# Get counting model.
|
96 |
def build_model_and_transforms(args):
|
97 |
normalize = T.Compose(
|
@@ -194,6 +196,7 @@ def get_ind_to_filter(text, word_ids, keywords):
|
|
194 |
|
195 |
return inds_to_filter
|
196 |
|
|
|
197 |
def count(image, text, prompts, state):
|
198 |
print("state: " + str(state))
|
199 |
keywords = "" # do not handle this for now
|
@@ -282,6 +285,7 @@ def count(image, text, prompts, state):
|
|
282 |
out_label = "Nothing specified to detect."
|
283 |
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)
|
284 |
|
|
|
285 |
def count_main(image, text, prompts):
|
286 |
keywords = "" # do not handle this for now
|
287 |
# Handle no prompt case.
|
|
|
1 |
+
import spaces
|
2 |
import gradio as gr
|
3 |
import copy
|
4 |
import random
|
|
|
93 |
parser.add_argument("--amp", action="store_true", help="Train with mixed precision")
|
94 |
return parser
|
95 |
|
96 |
+
@spaces.GPU
|
97 |
# Get counting model.
|
98 |
def build_model_and_transforms(args):
|
99 |
normalize = T.Compose(
|
|
|
196 |
|
197 |
return inds_to_filter
|
198 |
|
199 |
+
@spaces.GPU
|
200 |
def count(image, text, prompts, state):
|
201 |
print("state: " + str(state))
|
202 |
keywords = "" # do not handle this for now
|
|
|
285 |
out_label = "Nothing specified to detect."
|
286 |
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)
|
287 |
|
288 |
+
@spaces.GPU
|
289 |
def count_main(image, text, prompts):
|
290 |
keywords = "" # do not handle this for now
|
291 |
# Handle no prompt case.
|