atlury commited on
Commit
fea7704
·
verified ·
1 Parent(s): 73cd058

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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.inputs.Image(type="pil"),
34
- outputs=[gr.outputs.Image(type="pil", label="Annotated Image"),
35
- gr.outputs.Textbox(label="Detected Areas and Labels")]
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__":