Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,12 @@ from ultralytics import YOLO
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import os
|
|
|
6 |
|
7 |
# Ensure the model file is in the correct location
|
8 |
model_path = "yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt"
|
9 |
if not os.path.exists(model_path):
|
10 |
# Download the model file if it doesn't exist
|
11 |
-
import requests
|
12 |
model_url = "https://huggingface.co/DILHTWD/documentlayoutsegmentation_YOLOv8_ondoclaynet/resolve/main/yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt"
|
13 |
response = requests.get(model_url)
|
14 |
with open(model_path, "wb") as f:
|
@@ -30,9 +30,9 @@ def process_image(image):
|
|
30 |
# Define the Gradio interface
|
31 |
interface = gr.Interface(
|
32 |
fn=process_image,
|
33 |
-
inputs=gr.
|
34 |
-
outputs=[gr.
|
35 |
-
gr.
|
36 |
)
|
37 |
|
38 |
if __name__ == "__main__":
|
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import os
|
6 |
+
import requests
|
7 |
|
8 |
# Ensure the model file is in the correct location
|
9 |
model_path = "yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt"
|
10 |
if not os.path.exists(model_path):
|
11 |
# Download the model file if it doesn't exist
|
|
|
12 |
model_url = "https://huggingface.co/DILHTWD/documentlayoutsegmentation_YOLOv8_ondoclaynet/resolve/main/yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt"
|
13 |
response = requests.get(model_url)
|
14 |
with open(model_path, "wb") as f:
|
|
|
30 |
# Define the Gradio interface
|
31 |
interface = gr.Interface(
|
32 |
fn=process_image,
|
33 |
+
inputs=gr.Image(type="pil"),
|
34 |
+
outputs=[gr.Image(type="pil", label="Annotated Image"),
|
35 |
+
gr.Textbox(label="Detected Areas and Labels")]
|
36 |
)
|
37 |
|
38 |
if __name__ == "__main__":
|