sagar007 commited on
Commit
559f880
·
verified ·
1 Parent(s): ddc5032

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +137 -37
app.py CHANGED
@@ -20,27 +20,20 @@ def yolov9_inference(img_path, image_size, conf_threshold, iou_threshold):
20
 
21
  def app():
22
  with gr.Blocks() as demo:
23
- gr.HTML(
24
- """
25
- <div style="text-align: center; max-width: 800px; margin: 0 auto;">
26
- <h1 style="color: #2c3e50; font-size: 2.5em; margin-bottom: 0.5em;">YOLOv9: Manhole Detector</h1>
27
- <p style="color: #34495e; font-size: 1.2em; margin-bottom: 1em;">Detect manholes in images using YOLOv9</p>
28
- </div>
29
- """
30
- )
31
  with gr.Row():
32
  with gr.Column(scale=1, min_width=300):
33
  img_path = gr.Image(type="filepath", label="Upload Image")
34
- gr.Markdown("### Model Parameters")
35
  image_size = gr.Slider(label="Image Size", minimum=320, maximum=1280, step=32, value=640)
36
  conf_threshold = gr.Slider(label="Confidence Threshold", minimum=0.1, maximum=1.0, step=0.1, value=0.4)
37
  iou_threshold = gr.Slider(label="IoU Threshold", minimum=0.1, maximum=1.0, step=0.1, value=0.5)
38
- yolov9_infer = gr.Button("Detect Manholes", variant="primary")
39
 
40
  with gr.Column(scale=1, min_width=300):
41
  output_numpy = gr.Image(type="numpy", label="Detection Result")
42
 
43
- yolov9_infer.click(
44
  fn=yolov9_inference,
45
  inputs=[img_path, image_size, conf_threshold, iou_threshold],
46
  outputs=[output_numpy]
@@ -58,33 +51,140 @@ def app():
58
  )
59
 
60
  return demo
61
-
62
  css = """
63
- body {
64
- font-family: 'Arial', sans-serif;
65
- background-color: #f0f3f6;
66
- }
67
- .gradio-container {
68
- max-width: 900px !important;
69
- margin-left: auto !important;
70
- margin-right: auto !important;
71
- background-color: white;
72
- border-radius: 10px;
73
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
74
- padding: 20px;
75
- }
76
- .gr-button {
77
- background-color: #3498db !important;
78
- border: none !important;
79
- }
80
- .gr-button:hover {
81
- background-color: #2980b9 !important;
82
- }
83
- .gr-form {
84
- background-color: white;
85
- padding: 15px;
86
- border-radius: 8px;
87
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
  """
90
 
 
20
 
21
  def app():
22
  with gr.Blocks() as demo:
23
+ gr.HTML(HTML_TEMPLATE)
24
+
 
 
 
 
 
 
25
  with gr.Row():
26
  with gr.Column(scale=1, min_width=300):
27
  img_path = gr.Image(type="filepath", label="Upload Image")
 
28
  image_size = gr.Slider(label="Image Size", minimum=320, maximum=1280, step=32, value=640)
29
  conf_threshold = gr.Slider(label="Confidence Threshold", minimum=0.1, maximum=1.0, step=0.1, value=0.4)
30
  iou_threshold = gr.Slider(label="IoU Threshold", minimum=0.1, maximum=1.0, step=0.1, value=0.5)
31
+ detect_button = gr.Button("Detect Manholes", variant="primary")
32
 
33
  with gr.Column(scale=1, min_width=300):
34
  output_numpy = gr.Image(type="numpy", label="Detection Result")
35
 
36
+ detect_button.click(
37
  fn=yolov9_inference,
38
  inputs=[img_path, image_size, conf_threshold, iou_threshold],
39
  outputs=[output_numpy]
 
51
  )
52
 
53
  return demo
 
54
  css = """
55
+ <style>
56
+ body {
57
+ background: linear-gradient(135deg, #2c3e50, #34495e, #95a5a6);
58
+ font-family: 'Arial', sans-serif;
59
+ color: #ecf0f1;
60
+ }
61
+ #app-header {
62
+ text-align: center;
63
+ background: rgba(52, 73, 94, 0.9);
64
+ padding: 30px;
65
+ border-radius: 20px;
66
+ box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
67
+ position: relative;
68
+ overflow: hidden;
69
+ margin-bottom: 30px;
70
+ }
71
+ #app-header::before {
72
+ content: "";
73
+ position: absolute;
74
+ top: -50%;
75
+ left: -50%;
76
+ width: 200%;
77
+ height: 200%;
78
+ background: radial-gradient(circle, rgba(236,240,241,0.3) 0%, rgba(236,240,241,0) 70%);
79
+ animation: shimmer 15s infinite linear;
80
+ }
81
+ @keyframes shimmer {
82
+ 0% { transform: rotate(0deg); }
83
+ 100% { transform: rotate(360deg); }
84
+ }
85
+ #app-header h1 {
86
+ color: #e74c3c;
87
+ font-size: 2.5em;
88
+ margin-bottom: 15px;
89
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
90
+ }
91
+ #app-header p {
92
+ font-size: 1.2em;
93
+ color: #bdc3c7;
94
+ }
95
+ .feature-container {
96
+ display: flex;
97
+ justify-content: center;
98
+ gap: 30px;
99
+ margin-top: 30px;
100
+ flex-wrap: wrap;
101
+ }
102
+ .feature {
103
+ position: relative;
104
+ transition: transform 0.3s, box-shadow 0.3s;
105
+ border-radius: 15px;
106
+ overflow: hidden;
107
+ background: #2c3e50;
108
+ box-shadow: 0 5px 15px rgba(0,0,0,0.2);
109
+ }
110
+ .feature:hover {
111
+ transform: translateY(-10px) rotate(2deg);
112
+ box-shadow: 0 15px 30px rgba(0,0,0,0.3);
113
+ }
114
+ .feature-icon {
115
+ font-size: 3em;
116
+ padding: 20px;
117
+ color: #e74c3c;
118
+ }
119
+ .feature-description {
120
+ background-color: #34495e;
121
+ color: #ecf0f1;
122
+ padding: 10px;
123
+ font-size: 0.9em;
124
+ text-align: center;
125
+ }
126
+ .artifact {
127
+ position: absolute;
128
+ background: radial-gradient(circle, rgba(231,76,60,0.3) 0%, rgba(231,76,60,0) 70%);
129
+ border-radius: 50%;
130
+ opacity: 0.5;
131
+ }
132
+ .artifact.large {
133
+ width: 400px;
134
+ height: 400px;
135
+ top: -100px;
136
+ left: -200px;
137
+ animation: float 20s infinite ease-in-out;
138
+ }
139
+ .artifact.medium {
140
+ width: 300px;
141
+ height: 300px;
142
+ bottom: -150px;
143
+ right: -150px;
144
+ animation: float 15s infinite ease-in-out reverse;
145
+ }
146
+ .artifact.small {
147
+ width: 150px;
148
+ height: 150px;
149
+ top: 50%;
150
+ left: 50%;
151
+ transform: translate(-50%, -50%);
152
+ animation: pulse 5s infinite alternate;
153
+ }
154
+ @keyframes float {
155
+ 0%, 100% { transform: translateY(0) rotate(0deg); }
156
+ 50% { transform: translateY(-20px) rotate(10deg); }
157
+ }
158
+ @keyframes pulse {
159
+ 0% { transform: scale(1); opacity: 0.5; }
160
+ 100% { transform: scale(1.1); opacity: 0.8; }
161
+ }
162
+ </style>
163
+ <div id="app-header">
164
+ <div class="artifact large"></div>
165
+ <div class="artifact medium"></div>
166
+ <div class="artifact small"></div>
167
+ <h1>YOLOv9: Manhole Detector</h1>
168
+ <p>Detect manholes in images with advanced AI technology</p>
169
+ <div class="feature-container">
170
+ <div class="feature">
171
+ <div class="feature-icon">🔍</div>
172
+ <div class="feature-description">High Accuracy Detection</div>
173
+ </div>
174
+ <div class="feature">
175
+ <div class="feature-icon">⚡</div>
176
+ <div class="feature-description">Fast Processing</div>
177
+ </div>
178
+ <div class="feature">
179
+ <div class="feature-icon">🖼️</div>
180
+ <div class="feature-description">Image Size Adjustment</div>
181
+ </div>
182
+ <div class="feature">
183
+ <div class="feature-icon">🎚️</div>
184
+ <div class="feature-description">Customizable Thresholds</div>
185
+ </div>
186
+ </div>
187
+ </div>
188
  }
189
  """
190