Safi029 commited on
Commit
9508a99
·
verified ·
1 Parent(s): f27da67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -1,17 +1,24 @@
1
  import gradio as gr
2
  from ultralytics import YOLO
 
3
  from PIL import Image
4
 
5
- # Load your YOLO model (it must be in the same repo or use snapshot from Hugging Face Hub)
6
- model = YOLO("Safi029/ABD-model/blob/main/ABD.pt")
 
7
 
8
  def detect_structure(image):
9
  results = model(image)
10
- return results[0].plot() # Returns image with boxes
 
11
 
12
- gr.Interface(
13
  fn=detect_structure,
14
  inputs=gr.Image(type="pil"),
15
- outputs=gr.Image(type="numpy"),
16
- title="Molecular Structure Detection"
17
- ).launch()
 
 
 
 
 
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
+