nomypython commited on
Commit
53399a4
·
verified ·
1 Parent(s): ab60bae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -2,21 +2,19 @@ import gradio as gr
2
  from ultralytics import YOLO
3
  import os
4
 
5
- # Load the YOLO model
6
  model_path = "best.pt"
 
 
7
  model = YOLO(model_path)
8
 
9
  # Define the object detection function
10
  def detect_objects(image):
11
  results = model(image)
12
-
13
- # Extract logs from YOLO results
14
- logs = results[0].verbose()
15
-
16
- return results[0].plot(), logs # Return image + logs
17
 
18
  # Create a Gradio interface
19
- app = gr.Interface(fn=detect_objects, inputs="image", outputs=["image", "text"])
20
 
21
  # Launch Gradio app
22
- app.launch()
 
2
  from ultralytics import YOLO
3
  import os
4
 
5
+ # Download the model from Google Drive if it's not present
6
  model_path = "best.pt"
7
+
8
+ # Load the YOLOv8 model
9
  model = YOLO(model_path)
10
 
11
  # Define the object detection function
12
  def detect_objects(image):
13
  results = model(image)
14
+ return results[0].plot()
 
 
 
 
15
 
16
  # Create a Gradio interface
17
+ app = gr.Interface(fn=detect_objects, inputs="image", outputs="image")
18
 
19
  # Launch Gradio app
20
+ app.launch()