merve HF staff commited on
Commit
e615f64
1 Parent(s): d20f4f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,7 +1,4 @@
1
  from transformers import Owlv2Processor, Owlv2ForObjectDetection
2
-
3
- processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
4
- model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to("cuda")
5
  from typing import List
6
  import os
7
  import numpy as np
@@ -13,7 +10,10 @@ import gradio as gr
13
  import torch
14
  import numpy as np
15
  from PIL import Image
 
16
 
 
 
17
 
18
  BOUNDING_BOX_ANNOTATOR = sv.BoundingBoxAnnotator()
19
  MASK_ANNOTATOR = sv.MaskAnnotator()
@@ -74,7 +74,7 @@ def process_video(
74
  sink.write_frame(frame)
75
  return result_file_path
76
 
77
-
78
  def query(image, texts):
79
  inputs = processor(text=texts, images=image, return_tensors="pt").to("cuda")
80
  with torch.no_grad():
 
1
  from transformers import Owlv2Processor, Owlv2ForObjectDetection
 
 
 
2
  from typing import List
3
  import os
4
  import numpy as np
 
10
  import torch
11
  import numpy as np
12
  from PIL import Image
13
+ import spaces
14
 
15
+ processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
16
+ model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to("cuda")
17
 
18
  BOUNDING_BOX_ANNOTATOR = sv.BoundingBoxAnnotator()
19
  MASK_ANNOTATOR = sv.MaskAnnotator()
 
74
  sink.write_frame(frame)
75
  return result_file_path
76
 
77
+ @spaces.GPU
78
  def query(image, texts):
79
  inputs = processor(text=texts, images=image, return_tensors="pt").to("cuda")
80
  with torch.no_grad():