merve HF staff commited on
Commit
3298147
1 Parent(s): 0453d94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,7 +1,8 @@
1
  from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection
2
  import torch
3
  from transformers import SamModel, SamProcessor
4
-
 
5
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
6
 
7
  sam_model = SamModel.from_pretrained("facebook/sam-vit-base").to("cuda")
@@ -32,7 +33,7 @@ def infer_dino(img, text_queries, score_threshold):
32
  return results
33
 
34
 
35
- import numpy as np
36
  def query_image(img, text_queries, dino_threshold):
37
  text_queries = text_queries
38
  text_queries = text_queries.split(",")
@@ -76,6 +77,5 @@ demo = gr.Interface(
76
  examples=[
77
  ["./cats.png", "cat, fishnet", 0.16],["./bee.jpg", "bee, flower", 0.16]
78
  ],
79
- cache_examples=True
80
  )
81
  demo.launch(debug=True)
 
1
  from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection
2
  import torch
3
  from transformers import SamModel, SamProcessor
4
+ import spaces
5
+ import numpy as np
6
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
7
 
8
  sam_model = SamModel.from_pretrained("facebook/sam-vit-base").to("cuda")
 
33
  return results
34
 
35
 
36
+ @spaces.GPU
37
  def query_image(img, text_queries, dino_threshold):
38
  text_queries = text_queries
39
  text_queries = text_queries.split(",")
 
77
  examples=[
78
  ["./cats.png", "cat, fishnet", 0.16],["./bee.jpg", "bee, flower", 0.16]
79
  ],
 
80
  )
81
  demo.launch(debug=True)