File size: 1,100 Bytes
73f140c
7ab88d7
73f140c
 
7ab88d7
0504f58
73f140c
7ab88d7
1ace142
73f140c
 
7ab88d7
c6b32c4
7ab88d7
c6b32c4
6986251
c6b32c4
7ab88d7
 
 
 
 
 
 
 
 
 
 
 
 
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
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="mohamedrayyan/murakamodel", 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()