eldhoskj commited on
Commit
a44c9ea
1 Parent(s): 8987b46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -2,7 +2,6 @@ import cv2
2
  import numpy as np
3
  import gradio as gr
4
  import requests
5
- from io import BytesIO
6
 
7
  # Configuration files
8
  config_file = "ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt"
@@ -48,11 +47,7 @@ def detect_objects(frame):
48
  }
49
  detections.append(detected_object)
50
 
51
- # Draw bounding box and label on the frame
52
- cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
53
- cv2.putText(frame, classLabels[ClassInd - 1].upper(), (x, y-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
54
-
55
- return frame, detections
56
 
57
  def get_image_from_url(url):
58
  response = requests.get(url)
@@ -62,16 +57,16 @@ def get_image_from_url(url):
62
 
63
  def detect_objects_in_image_url(url):
64
  frame = get_image_from_url(url)
65
- result_frame, detected_objects = detect_objects(frame)
66
- return result_frame, detected_objects
67
 
68
  # Define the Gradio interface
69
  iface = gr.Interface(
70
  fn=detect_objects_in_image_url,
71
  inputs="text",
72
- outputs=[gr.Image(type="numpy"), gr.JSON()],
73
  title="Object Detection",
74
- description="Enter an image URL to detect objects. The bounding boxes and labels will be drawn on the image, and the detected objects will be returned as JSON."
75
  )
76
 
77
  # Launch the interface
 
2
  import numpy as np
3
  import gradio as gr
4
  import requests
 
5
 
6
  # Configuration files
7
  config_file = "ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt"
 
47
  }
48
  detections.append(detected_object)
49
 
50
+ return detections
 
 
 
 
51
 
52
  def get_image_from_url(url):
53
  response = requests.get(url)
 
57
 
58
  def detect_objects_in_image_url(url):
59
  frame = get_image_from_url(url)
60
+ detected_objects = detect_objects(frame)
61
+ return detected_objects
62
 
63
  # Define the Gradio interface
64
  iface = gr.Interface(
65
  fn=detect_objects_in_image_url,
66
  inputs="text",
67
+ outputs=gr.JSON(),
68
  title="Object Detection",
69
+ description="Enter an image URL to detect objects. The detected objects will be returned as JSON."
70
  )
71
 
72
  # Launch the interface