muraka-ai / app.py
Atolla's picture
Upload app.py
676ab81 verified
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()