Aumkeshchy2003 commited on
Commit
7ea3de0
·
verified ·
1 Parent(s): d33fcea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,29 +1,27 @@
1
  import gradio as gr
2
  from ultralytics import YOLO
3
 
4
- # Load your trained YOLOv8n model
5
- # Ensure 'yolov8n.pt' is in the repository or provide the correct path.
6
  model = YOLO("best (1).pt")
7
 
8
  def detect(image):
9
 
10
- # Run inference
11
  results = model(image)
12
 
13
- # Use the first result and plot detections on the image
14
  annotated_image = results[0].plot()
15
  return annotated_image
16
 
17
- # Build Gradio Interface
18
  iface = gr.Interface(
19
  fn=detect,
20
  inputs=gr.Image(type="numpy", label="Input Image"),
21
  outputs=gr.Image(type="numpy", label="Detection Output"),
22
  title="Solar Panel Detection",
23
  description="Upload an image, and the model will detect the Solar Panels.",
24
- examples=["solarpanels_native_3__x0_10924_y0_9818_dxdy_416.jpg", "solarpanels_native_3__x0_12671_y0_11008_dxdy_416.jpg"]
 
25
  )
26
 
27
- # Launch the interface (Hugging Face Spaces will automatically run the app)
28
  if __name__ == "__main__":
29
  iface.launch()
 
1
  import gradio as gr
2
  from ultralytics import YOLO
3
 
 
 
4
  model = YOLO("best (1).pt")
5
 
6
  def detect(image):
7
 
8
+ # Running inference
9
  results = model(image)
10
 
 
11
  annotated_image = results[0].plot()
12
  return annotated_image
13
 
14
+ # Building Gradio Interface
15
  iface = gr.Interface(
16
  fn=detect,
17
  inputs=gr.Image(type="numpy", label="Input Image"),
18
  outputs=gr.Image(type="numpy", label="Detection Output"),
19
  title="Solar Panel Detection",
20
  description="Upload an image, and the model will detect the Solar Panels.",
21
+ examples=["solarpanels_native_3__x0_10924_y0_9818_dxdy_416.jpg",
22
+ "solarpanels_native_3__x0_12671_y0_11008_dxdy_416.jpg"]
23
  )
24
 
25
+ # Launching the interface (Hugging Face Spaces will automatically run the app)
26
  if __name__ == "__main__":
27
  iface.launch()