sakthi54321 commited on
Commit
1c7248a
·
verified ·
1 Parent(s): b3af240

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -18,9 +18,9 @@ class_names = {
18
  5: "Copper",
19
  } if not model.names else model.names # Use model.names if available
20
 
21
- def detect_pcb_faults(image):
22
- """Runs YOLOv8 on the input image and returns detected defects."""
23
- results = model(image, conf=0.18) # 🔥 Lower confidence to detect more defects
24
 
25
  boxes = results[0].boxes.xyxy.cpu().numpy() # Extract bounding boxes
26
  confs = results[0].boxes.conf.cpu().numpy() # Extract confidence scores
@@ -38,11 +38,14 @@ def detect_pcb_faults(image):
38
 
39
  return image
40
 
41
- # ✅ Gradio UI for PCB Fault Detection
42
  gr.Interface(
43
  fn=detect_pcb_faults,
44
- inputs=gr.Image(type="numpy"),
 
 
 
45
  outputs=gr.Image(type="numpy"),
46
  title="PCB Fault Detection",
47
- description="Upload a PCB image to detect defects using YOLOv8. The model will highlight and label detected faults."
48
  ).launch()
 
18
  5: "Copper",
19
  } if not model.names else model.names # Use model.names if available
20
 
21
+ def detect_pcb_faults(image, conf_threshold):
22
+ """Runs YOLOv8 on the input image with an adjustable confidence threshold."""
23
+ results = model(image, conf=conf_threshold) # 🔥 Adjustable confidence
24
 
25
  boxes = results[0].boxes.xyxy.cpu().numpy() # Extract bounding boxes
26
  confs = results[0].boxes.conf.cpu().numpy() # Extract confidence scores
 
38
 
39
  return image
40
 
41
+ # ✅ Gradio UI with Confidence Threshold Slider
42
  gr.Interface(
43
  fn=detect_pcb_faults,
44
+ inputs=[
45
+ gr.Image(type="numpy"),
46
+ gr.Slider(minimum=0.1, maximum=0.9, value=0.18, label="Confidence Threshold")
47
+ ],
48
  outputs=gr.Image(type="numpy"),
49
  title="PCB Fault Detection",
50
+ description="Upload a PCB image to detect defects using YOLOv8. Adjust the confidence threshold to fine-tune detections."
51
  ).launch()