NaveenKumar5 commited on
Commit
22e4b35
·
verified ·
1 Parent(s): 15f7d72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -33
app.py CHANGED
@@ -1,37 +1,11 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
- from PIL import Image
4
 
5
- # Load the model from Hugging Face Hub
6
- model = pipeline("object-detection", model="NaveenKumar5/Solar_panel_fault_detection")
7
-
8
- def detect_faults(image):
9
- results = model(image)
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
- demo.launch()
 
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()