adirik commited on
Commit
2e8fd00
·
1 Parent(s): 9940ce7
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -17,12 +17,11 @@ processor = OwlViTProcessor.from_pretrained("google/owlvit-base-patch32")
17
 
18
 
19
  def image_guided_detection(img, query_img, score_threshold, nms_threshold):
20
- target_sizes = torch.Tensor([img.shape[:2]])
 
21
  print(type(img), type(query_img))
22
- print(img.shape)
23
- print(query_img.shape)
24
- print(processor)
25
- print()
26
  inputs = processor(query_images=query_img, images=img, return_tensors="pt").to(device)
27
  print(inputs)
28
  print()
@@ -41,6 +40,7 @@ def image_guided_detection(img, query_img, score_threshold, nms_threshold):
41
  )
42
 
43
  boxes, scores = results[0]["boxes"], results[0]["scores"]
 
44
 
45
  for box, score in zip(boxes, scores):
46
  box = [int(i) for i in box.tolist()]
@@ -72,7 +72,7 @@ example / query image of the target object. To use it, simply upload an image an
72
 
73
  demo = gr.Interface(
74
  image_guided_detection,
75
- inputs=[gr.Image(), gr.Image(), gr.Slider(0, 1, value=0.6), gr.Slider(0, 1, value=0.3)],
76
  outputs="image",
77
  title="Image-Guided Object Detection with OWL-ViT",
78
  description=description,
 
17
 
18
 
19
  def image_guided_detection(img, query_img, score_threshold, nms_threshold):
20
+ target_sizes = torch.Tensor([img.size[::-1]])
21
+ print(target_sizes)
22
  print(type(img), type(query_img))
23
+ print(img.size)
24
+ print(query_img.size)
 
 
25
  inputs = processor(query_images=query_img, images=img, return_tensors="pt").to(device)
26
  print(inputs)
27
  print()
 
40
  )
41
 
42
  boxes, scores = results[0]["boxes"], results[0]["scores"]
43
+ img = np.asarray(img)
44
 
45
  for box, score in zip(boxes, scores):
46
  box = [int(i) for i in box.tolist()]
 
72
 
73
  demo = gr.Interface(
74
  image_guided_detection,
75
+ inputs=[gr.Image(type="pil"), gr.Image(type="pil"), gr.Slider(0, 1, value=0.6), gr.Slider(0, 1, value=0.3)],
76
  outputs="image",
77
  title="Image-Guided Object Detection with OWL-ViT",
78
  description=description,