merve HF staff commited on
Commit
c7b56d5
1 Parent(s): a3c1650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -12,7 +12,6 @@ import numpy as np
12
  from PIL import Image
13
  import spaces
14
 
15
-
16
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
17
  processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
18
  model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to(device)
@@ -40,8 +39,7 @@ def annotate_image(
40
  output_image = LABEL_ANNOTATOR.annotate(output_image, detections, labels=labels)
41
  return output_image
42
 
43
-
44
-
45
  def process_video(
46
  input_video,
47
  labels,
@@ -63,7 +61,6 @@ def process_video(
63
  # list of dict of {"box": box, "mask":mask, "score":score, "label":label}
64
  results = query(frame, labels)
65
 
66
- #detections = sv.Detections.empty()
67
  detections = sv.Detections.from_transformers(results[0])
68
  final_labels = []
69
  for id in results[0]["labels"]:
@@ -76,7 +73,6 @@ def process_video(
76
  sink.write_frame(frame)
77
  return result_file_path
78
 
79
- @spaces.GPU
80
  def query(image, texts):
81
  inputs = processor(text=texts, images=image, return_tensors="pt").to(device)
82
  with torch.no_grad():
 
12
  from PIL import Image
13
  import spaces
14
 
 
15
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
  processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
17
  model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to(device)
 
39
  output_image = LABEL_ANNOTATOR.annotate(output_image, detections, labels=labels)
40
  return output_image
41
 
42
+ @spaces.GPU
 
43
  def process_video(
44
  input_video,
45
  labels,
 
61
  # list of dict of {"box": box, "mask":mask, "score":score, "label":label}
62
  results = query(frame, labels)
63
 
 
64
  detections = sv.Detections.from_transformers(results[0])
65
  final_labels = []
66
  for id in results[0]["labels"]:
 
73
  sink.write_frame(frame)
74
  return result_file_path
75
 
 
76
  def query(image, texts):
77
  inputs = processor(text=texts, images=image, return_tensors="pt").to(device)
78
  with torch.no_grad():