Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ def run_inference(image):
|
|
| 29 |
|
| 30 |
return annotated_image, count_text
|
| 31 |
|
| 32 |
-
# Create the Gradio interface
|
| 33 |
interface = gr.Interface(
|
| 34 |
fn=run_inference,
|
| 35 |
inputs=gr.Image(type="pil"),
|
|
@@ -38,7 +38,94 @@ interface = gr.Interface(
|
|
| 38 |
gr.Textbox(label="Object Counts", lines=5, interactive=False) # Display counts as text
|
| 39 |
],
|
| 40 |
title="YOLOv5 Object Detection with Counts",
|
| 41 |
-
description="Upload an image to run YOLOv5 object detection, see the annotated results, and view the count of detected objects by category."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
# Launch the app
|
|
|
|
| 29 |
|
| 30 |
return annotated_image, count_text
|
| 31 |
|
| 32 |
+
# Create the Gradio interface with enhanced UI
|
| 33 |
interface = gr.Interface(
|
| 34 |
fn=run_inference,
|
| 35 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 38 |
gr.Textbox(label="Object Counts", lines=5, interactive=False) # Display counts as text
|
| 39 |
],
|
| 40 |
title="YOLOv5 Object Detection with Counts",
|
| 41 |
+
description="Upload an image to run YOLOv5 object detection, see the annotated results, and view the count of detected objects by category.",
|
| 42 |
+
css="""
|
| 43 |
+
body {
|
| 44 |
+
font-family: 'Arial', sans-serif;
|
| 45 |
+
background: linear-gradient(135deg, #FF6F61, #FF9F9F, #FFEB3B);
|
| 46 |
+
animation: gradientBG 5s ease infinite;
|
| 47 |
+
margin: 0;
|
| 48 |
+
padding: 0;
|
| 49 |
+
color: white;
|
| 50 |
+
height: 100vh;
|
| 51 |
+
display: flex;
|
| 52 |
+
justify-content: center;
|
| 53 |
+
align-items: center;
|
| 54 |
+
text-align: center;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
@keyframes gradientBG {
|
| 58 |
+
0% { background-position: 0% 50%; }
|
| 59 |
+
50% { background-position: 100% 50%; }
|
| 60 |
+
100% { background-position: 0% 50%; }
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.gradio-container {
|
| 64 |
+
background: rgba(0, 0, 0, 0.5);
|
| 65 |
+
border-radius: 20px;
|
| 66 |
+
padding: 20px;
|
| 67 |
+
width: 90%;
|
| 68 |
+
max-width: 700px;
|
| 69 |
+
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.5);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.gradio-header {
|
| 73 |
+
font-size: 2.5rem;
|
| 74 |
+
font-weight: bold;
|
| 75 |
+
color: #FFEB3B;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.gradio-description {
|
| 79 |
+
font-size: 1.2rem;
|
| 80 |
+
color: #ffffff;
|
| 81 |
+
margin-top: 10px;
|
| 82 |
+
font-style: italic;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.gr-button {
|
| 86 |
+
background: linear-gradient(90deg, #FF6F61, #FF9F9F);
|
| 87 |
+
color: white;
|
| 88 |
+
padding: 1rem 2rem;
|
| 89 |
+
font-size: 1.1rem;
|
| 90 |
+
border-radius: 10px;
|
| 91 |
+
border: none;
|
| 92 |
+
cursor: pointer;
|
| 93 |
+
transition: transform 0.3s ease, background 0.3s ease;
|
| 94 |
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.gr-button:hover {
|
| 98 |
+
background: linear-gradient(90deg, #FF9F9F, #FF6F61);
|
| 99 |
+
transform: scale(1.05);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.gr-button:active {
|
| 103 |
+
background: linear-gradient(90deg, #FF6F61, #FF9F9F);
|
| 104 |
+
transform: scale(1.1);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.gr-image-container {
|
| 108 |
+
margin-top: 20px;
|
| 109 |
+
border-radius: 15px;
|
| 110 |
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.gr-textbox {
|
| 114 |
+
background-color: #333;
|
| 115 |
+
color: #FFEB3B;
|
| 116 |
+
border: none;
|
| 117 |
+
padding: 10px;
|
| 118 |
+
border-radius: 10px;
|
| 119 |
+
font-size: 1rem;
|
| 120 |
+
width: 100%;
|
| 121 |
+
text-align: left;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.gr-textbox:focus {
|
| 125 |
+
outline: none;
|
| 126 |
+
border: 2px solid #FF6F61;
|
| 127 |
+
}
|
| 128 |
+
"""
|
| 129 |
)
|
| 130 |
|
| 131 |
# Launch the app
|