Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
def detect_structure(image):
|
| 9 |
results = model(image)
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
gr.Interface(
|
| 13 |
fn=detect_structure,
|
| 14 |
inputs=gr.Image(type="pil"),
|
| 15 |
-
outputs=gr.Image(type="
|
| 16 |
-
title="Molecular Structure
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
+
# ✅ Download your model from Hugging Face Hub
|
| 7 |
+
model_path = hf_hub_download(repo_id="Safi029/ABD-model", filename="ABD.pt")
|
| 8 |
+
model = YOLO(model_path)
|
| 9 |
|
| 10 |
def detect_structure(image):
|
| 11 |
results = model(image)
|
| 12 |
+
annotated_img = results[0].plot()
|
| 13 |
+
return Image.fromarray(annotated_img)
|
| 14 |
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
fn=detect_structure,
|
| 17 |
inputs=gr.Image(type="pil"),
|
| 18 |
+
outputs=gr.Image(type="pil"),
|
| 19 |
+
title="YOLO Molecular Structure Reader",
|
| 20 |
+
description="Upload a molecular structure image. The YOLO model will detect atoms and bonds."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
demo.launch()
|
| 24 |
+
|