# app.py import gradio as gr from ultralytics import YOLO from PIL import Image # Load the YOLOv8 model model = YOLO("yolo_weights/yolov8n.pt") # path to your weights def detect_objects(img): results = model(img) result_img = results[0].plot() # render boxes on the image return Image.fromarray(result_img) # Gradio UI demo = 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()