Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,24 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
model = YOLOvv8.from_pretrained("keremberke/yolov8n-pcb-defect-segmentation")
|
4 |
-
source = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
5 |
-
model.predict(source=source, save=True)
|
|
|
1 |
+
import torch
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
import gradio as gr
|
5 |
+
from ultralytics import YOLO
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
# Modeli yükleme
|
9 |
+
model = YOLO("keremberke/yolov8n-pcb-defect-segmentation")
|
10 |
+
|
11 |
+
def detect_defects(image):
|
12 |
+
results = model.predict(image, save=False)
|
13 |
+
annotated_image = results[0].plot() # Tahmin sonuçlarını çiz
|
14 |
+
return annotated_image
|
15 |
+
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=detect_defects,
|
18 |
+
inputs=gr.Image(type="pil"),
|
19 |
+
outputs=gr.Image(type="pil"),
|
20 |
+
title="PCB Defect Segmentation"
|
21 |
+
)
|
22 |
+
|
23 |
+
iface.launch()
|
24 |
|
|
|
|
|
|