Download app.py from Smarrter/FirstYolo: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/Smarrter/FirstYolo/resolve/main/app.py
- Command line
-
hf download hf://spaces/Smarrter/FirstYolo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Smarrter/FirstYolo/resolve/main/app.py
687 Bytes
| # 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() | |