Update app.py
Browse files123456789101112131415161718192021import gradio as grfrom ultralytics import YOLOimport os# Load the YOLO model (make sure the file exists in your space!)model = YOLO("yolo_weights/yolov8n.pt") # Replace with your actual model pathdef detect(image):results = model(image)annotated = results[0].plot() # Annotated imagereturn annotatedinterface = gr.Interface(fn=detect,inputs=gr.Image(type="pil"),outputs=gr.Image(type="pil"),title="Fresh Bytes - Lunar Detection Model",description="Upload a lunar image to detect boulders or landslides using YOLO.")interface.launch()123456789101112131415161718192021222324# app.pyimport gradio as grfrom ultralytics import YOLOfrom PIL import Image# Load the YOLOv8 modelmodel = YOLO("yolo_weights/yolov8n.pt") # path to your weightsdef detect_objects(img):results = model(img)result_img = results[0].plot() # render boxes on the imagereturn Image.fromarray(result_img)# Gradio UIdemo = gr.Interface(fn=detect_objects,inputs=gr.Image(type="pil", label="Upload Lunar Image"),outputs=gr.Image(type="pil", label="Detection Output"),title="Lunar Landslide & Boulder Detector",description="This interface uses a YOLOv8 model to detect lunar geological features.")if __name__ == "__main__":demo.launch()
app.py+17-14