lary925 commited on
Commit
f856a33
·
verified ·
1 Parent(s): 7242657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -24,16 +24,7 @@ def predict_image(input_image):
24
  img_bgr = result[0].plot()
25
  img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB) # Convert BGR to RGB
26
  output_image = Image.fromarray(img_rgb) # Use the RGB image for output
27
-
28
- # Get the original filename (without path)
29
- original_filename = os.path.basename(input_image.name)
30
-
31
- # Get the name without the extension and append '_detected'
32
- base_filename, _ = os.path.splitext(original_filename)
33
- output_image_jpg = base_filename + "_detected.jpg"
34
- output_image.save(output_image_jpg, "JPEG")
35
-
36
- return output_image_jpg # Return path to saved JPG image
37
 
38
  # Video prediction function
39
  def predict_video(input_video):
@@ -83,8 +74,8 @@ with gr.Blocks() as app:
83
  with gr.Tabs():
84
  with gr.Tab("Image Detection"):
85
  gr.Interface(fn=predict_image,
86
- inputs=gr.File(type="pil", label="Upload Image"),
87
- outputs=gr.File(type="pil", label="Download Image"),
88
  title="Image Object Detection",
89
  description="Upload an image to detect Wildebeest and/or Hyena.")
90
 
 
24
  img_bgr = result[0].plot()
25
  img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB) # Convert BGR to RGB
26
  output_image = Image.fromarray(img_rgb) # Use the RGB image for output
27
+ return output_image
 
 
 
 
 
 
 
 
 
28
 
29
  # Video prediction function
30
  def predict_video(input_video):
 
74
  with gr.Tabs():
75
  with gr.Tab("Image Detection"):
76
  gr.Interface(fn=predict_image,
77
+ inputs=gr.Image(type="pil", label="Upload Image"),
78
+ outputs=gr.Image(type="pil", label="Download Image"),
79
  title="Image Object Detection",
80
  description="Upload an image to detect Wildebeest and/or Hyena.")
81