techysanoj commited on
Commit
f7b8ab6
·
1 Parent(s): ab2f3ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -8,7 +8,6 @@ from transformers import DetrImageProcessor, DetrForObjectDetection
8
  processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
9
  model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
10
 
11
- # Define the object detection function
12
  def detect_objects(frame):
13
  # Convert the frame to PIL image
14
  image = Image.fromarray(frame)
@@ -28,7 +27,8 @@ def detect_objects(frame):
28
  box = [round(i, 2) for i in box.tolist()]
29
  frame = gr.draw_box(frame, box, label=model.config.id2label[label.item()], color=(0, 255, 0))
30
 
31
- return frame
 
32
 
33
  # Define the Gradio interface
34
  iface = gr.Interface(
 
8
  processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
9
  model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
10
 
 
11
  def detect_objects(frame):
12
  # Convert the frame to PIL image
13
  image = Image.fromarray(frame)
 
27
  box = [round(i, 2) for i in box.tolist()]
28
  frame = gr.draw_box(frame, box, label=model.config.id2label[label.item()], color=(0, 255, 0))
29
 
30
+ # Convert frame back to numpy array for Gradio
31
+ return np.array(frame)
32
 
33
  # Define the Gradio interface
34
  iface = gr.Interface(