File size: 1,093 Bytes
676ab81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

import torch
import cv2
import gradio as gr
from ultralytics import YOLO
import numpy as np
from huggingface_hub import hf_hub_download

# Download and load model
model_path = hf_hub_download(repo_id="At0lla/Muraka_ai", filename="best.pt")
model = YOLO(model_path)

# Detection function with confidence threshold
def detect_objects(image, confidence_threshold):
    results = model(image, conf=confidence_threshold)  # Use confidence threshold
    annotated_frame = results[0].plot()
    return annotated_frame

# Create Gradio interface with slider
gr.Interface(
    fn=detect_objects,
    inputs=[
        gr.Image(type="numpy", label="Upload Coral Image"),
        gr.Slider(0.0, 1.0, value=0.25, label="Confidence Threshold", 
                 info="Lower = more sensitive, Higher = fewer false positives")
    ],
    outputs=gr.Image(type="numpy", label="Analysis Results"),
    title="🪸 Muraka - AI Doctor for Corals",
    description="Upload coral images to assess health status. Adjust confidence threshold to control detection sensitivity.",
    allow_flagging="never"
).launch()