YONG627 commited on
Commit
bdabcee
·
verified ·
1 Parent(s): 4ce1e33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -1,10 +1,9 @@
1
  import gradio as gr
2
- import sahi
3
  import torch
4
  from ultralyticsplus import YOLO, render_model_output
5
 
6
-
7
-
8
  model_names = [
9
  "yolov8n-seg.pt",
10
  "yolov8s-seg.pt",
@@ -53,6 +52,7 @@ def yolov8_inference(
53
  return renders[0]
54
 
55
 
 
56
  inputs = [
57
  gr.Image(type="filepath", label="Input Image"),
58
  gr.Dropdown(
@@ -68,13 +68,15 @@ inputs = [
68
  ]
69
 
70
  outputs = gr.Image(type="filepath", label="Output Image")
71
- title = "Ultralytics YOLOv8 Segmentation Demo"
72
 
 
 
73
  examples = [
74
  ["ikun.jpg", "yolov8m-seg.pt", 640, 0.6, 0.45],
75
  ["people.png", "yolov8m-seg.pt", 640, 0.25, 0.45],
76
-
77
  ]
 
 
78
  demo_app = gr.Interface(
79
  fn=yolov8_inference,
80
  inputs=inputs,
@@ -84,4 +86,15 @@ demo_app = gr.Interface(
84
  cache_examples=True,
85
  theme="default",
86
  )
 
 
 
 
 
 
 
 
 
 
 
87
  demo_app.launch(debug=True, enable_queue=True)
 
1
  import gradio as gr
2
+ from gradio.mix import SquareImageMixin
3
  import torch
4
  from ultralyticsplus import YOLO, render_model_output
5
 
6
+ # Define the model names
 
7
  model_names = [
8
  "yolov8n-seg.pt",
9
  "yolov8s-seg.pt",
 
52
  return renders[0]
53
 
54
 
55
+ # Define the input and output components
56
  inputs = [
57
  gr.Image(type="filepath", label="Input Image"),
58
  gr.Dropdown(
 
68
  ]
69
 
70
  outputs = gr.Image(type="filepath", label="Output Image")
 
71
 
72
+ # Define the title and examples
73
+ title = "Ultralytics YOLOv8 Segmentation Demo"
74
  examples = [
75
  ["ikun.jpg", "yolov8m-seg.pt", 640, 0.6, 0.45],
76
  ["people.png", "yolov8m-seg.pt", 640, 0.25, 0.45],
 
77
  ]
78
+
79
+ # Create the Gradio interface
80
  demo_app = gr.Interface(
81
  fn=yolov8_inference,
82
  inputs=inputs,
 
86
  cache_examples=True,
87
  theme="default",
88
  )
89
+
90
+ # Set the custom CSS style with background image
91
+ demo_app.css = """
92
+ body {
93
+ background-image: url('backbone.jpg'); /* URL of your background image */
94
+ background-size: cover; /* Cover the entire interface */
95
+ background-position: center; /* Center the background image */
96
+ }
97
+ """
98
+
99
+ # Launch the interface
100
  demo_app.launch(debug=True, enable_queue=True)