merve HF staff commited on
Commit
ad7e7b4
β€’
1 Parent(s): 426e73b
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -1,12 +1,14 @@
1
  from transformers import pipeline, SamModel, SamProcessor
2
  import torch
3
  import numpy as np
 
4
 
5
  checkpoint = "google/owlvit-base-patch16"
6
  detector = pipeline(model=checkpoint, task="zero-shot-object-detection")
7
  sam_model = SamModel.from_pretrained("facebook/sam-vit-base").to("cuda")
8
  sam_processor = SamProcessor.from_pretrained("facebook/sam-vit-base")
9
 
 
10
  def query(image, texts, threshold):
11
  texts = texts.split(",")
12
  print(texts)
 
1
  from transformers import pipeline, SamModel, SamProcessor
2
  import torch
3
  import numpy as np
4
+ import spaces
5
 
6
  checkpoint = "google/owlvit-base-patch16"
7
  detector = pipeline(model=checkpoint, task="zero-shot-object-detection")
8
  sam_model = SamModel.from_pretrained("facebook/sam-vit-base").to("cuda")
9
  sam_processor = SamProcessor.from_pretrained("facebook/sam-vit-base")
10
 
11
+ @spaces.GPU
12
  def query(image, texts, threshold):
13
  texts = texts.split(",")
14
  print(texts)