Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import Owlv2Processor, Owlv2ForObjectDetection
|
| 4 |
-
|
| 5 |
|
| 6 |
# Use GPU if available
|
| 7 |
if torch.cuda.is_available():
|
|
@@ -12,7 +12,7 @@ else:
|
|
| 12 |
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to(device)
|
| 13 |
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
|
| 14 |
|
| 15 |
-
|
| 16 |
def query_image(img, text_queries, score_threshold):
|
| 17 |
text_queries = text_queries
|
| 18 |
text_queries = text_queries.split(",")
|
|
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import Owlv2Processor, Owlv2ForObjectDetection
|
| 4 |
+
import spaces
|
| 5 |
|
| 6 |
# Use GPU if available
|
| 7 |
if torch.cuda.is_available():
|
|
|
|
| 12 |
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to(device)
|
| 13 |
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
|
| 14 |
|
| 15 |
+
@spaces.GPU
|
| 16 |
def query_image(img, text_queries, score_threshold):
|
| 17 |
text_queries = text_queries
|
| 18 |
text_queries = text_queries.split(",")
|