Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
from PIL import Image
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
annotated_image = image.copy()
|
| 11 |
-
|
| 12 |
-
for result in results:
|
| 13 |
-
box = result["box"]
|
| 14 |
-
label = result["label"]
|
| 15 |
-
score = result["score"]
|
| 16 |
-
|
| 17 |
-
annotated_image = annotated_image.convert("RGB")
|
| 18 |
-
draw = ImageDraw.Draw(annotated_image)
|
| 19 |
-
draw.rectangle(
|
| 20 |
-
[box["xmin"], box["ymin"], box["xmax"], box["ymax"]],
|
| 21 |
-
outline="red",
|
| 22 |
-
width=3
|
| 23 |
-
)
|
| 24 |
-
draw.text((box["xmin"], box["ymin"] - 10), f"{label} ({score:.2f})", fill="red")
|
| 25 |
-
|
| 26 |
-
return annotated_image
|
| 27 |
-
|
| 28 |
-
demo = gr.Interface(
|
| 29 |
-
fn=detect_faults,
|
| 30 |
-
inputs=gr.Image(type="pil"),
|
| 31 |
-
outputs=gr.Image(type="pil"),
|
| 32 |
-
title="Solar Panel Fault Detection",
|
| 33 |
-
description="Upload an image of a solar panel to detect faults using a custom-trained model."
|
| 34 |
-
)
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from inference import predict
|
|
|
|
| 3 |
|
| 4 |
+
iface = gr.Interface(fn=predict,
|
| 5 |
+
inputs=gr.Image(type="pil"),
|
| 6 |
+
outputs="image",
|
| 7 |
+
title="Solar Panel Fault Detection",
|
| 8 |
+
description="Upload a thermal image of a solar panel to detect faults using YOLOv5/Roboflow model.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
if __name__ == "__main__":
|
| 11 |
+
iface.launch()
|