Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,13 +59,14 @@ custom_css = """
|
|
| 59 |
.btn-primary { @apply bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition; }
|
| 60 |
h1 { @apply text-3xl font-bold text-gray-800 mb-4; }
|
| 61 |
.input-label { @apply text-sm font-medium text-gray-600 mb-2; }
|
|
|
|
| 62 |
</style>
|
| 63 |
"""
|
| 64 |
|
| 65 |
# Gradio interface
|
| 66 |
with gr.Blocks(css=custom_css) as demo:
|
| 67 |
gr.HTML("<h1 class='text-center'>OpenCV Multi-Feature Demo</h1>")
|
| 68 |
-
gr.Markdown("Upload an image and explore various OpenCV features using the tabs below.",
|
| 69 |
|
| 70 |
image_input = gr.Image(label="Upload Image", type="pil")
|
| 71 |
|
|
@@ -73,7 +74,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 73 |
with gr.TabItem("Grayscale", elem_classes="tab-button"):
|
| 74 |
with gr.Row():
|
| 75 |
with gr.Column():
|
| 76 |
-
gr.Markdown("Convert the image to grayscale.",
|
| 77 |
grayscale_button = gr.Button("Apply Grayscale", elem_classes="btn-primary")
|
| 78 |
with gr.Column():
|
| 79 |
grayscale_output = gr.Image(label="Grayscale Result")
|
|
@@ -82,7 +83,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 82 |
with gr.TabItem("Canny Edge Detection", elem_classes="tab-button"):
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column():
|
| 85 |
-
gr.Markdown("Detect edges with adjustable thresholds.",
|
| 86 |
canny_t1 = gr.Slider(0, 500, value=100, step=10, label="Threshold 1")
|
| 87 |
canny_t2 = gr.Slider(0, 500, value=200, step=10, label="Threshold 2")
|
| 88 |
canny_button = gr.Button("Apply Canny", elem_classes="btn-primary")
|
|
@@ -93,7 +94,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 93 |
with gr.TabItem("Gaussian Blur", elem_classes="tab-button"):
|
| 94 |
with gr.Row():
|
| 95 |
with gr.Column():
|
| 96 |
-
gr.Markdown("Apply Gaussian blur with adjustable kernel size.",
|
| 97 |
blur_kernel = gr.Slider(3, 21, value=5, step=2, label="Kernel Size")
|
| 98 |
blur_button = gr.Button("Apply Blur", elem_classes="btn-primary")
|
| 99 |
with gr.Column():
|
|
@@ -103,7 +104,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 103 |
with gr.TabItem("Face Detection", elem_classes="tab-button"):
|
| 104 |
with gr.Row():
|
| 105 |
with gr.Column():
|
| 106 |
-
gr.Markdown("Detect faces using Haar Cascade.",
|
| 107 |
face_button = gr.Button("Detect Faces", elem_classes="btn-primary")
|
| 108 |
with gr.Column():
|
| 109 |
face_output = gr.Image(label="Faces Detected")
|
|
@@ -112,7 +113,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 112 |
with gr.TabItem("Color Space Conversion", elem_classes="tab-button"):
|
| 113 |
with gr.Row():
|
| 114 |
with gr.Column():
|
| 115 |
-
gr.Markdown("Convert between RGB, HSV, and LAB color spaces.",
|
| 116 |
color_space = gr.Dropdown(choices=["RGB", "HSV", "LAB"], label="Color Space", value="RGB")
|
| 117 |
color_button = gr.Button("Apply Conversion", elem_classes="btn-primary")
|
| 118 |
with gr.Column():
|
|
|
|
| 59 |
.btn-primary { @apply bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition; }
|
| 60 |
h1 { @apply text-3xl font-bold text-gray-800 mb-4; }
|
| 61 |
.input-label { @apply text-sm font-medium text-gray-600 mb-2; }
|
| 62 |
+
.markdown-style { @apply text-center text-gray-600 mb-4; }
|
| 63 |
</style>
|
| 64 |
"""
|
| 65 |
|
| 66 |
# Gradio interface
|
| 67 |
with gr.Blocks(css=custom_css) as demo:
|
| 68 |
gr.HTML("<h1 class='text-center'>OpenCV Multi-Feature Demo</h1>")
|
| 69 |
+
gr.Markdown("Upload an image and explore various OpenCV features using the tabs below.", elem_classes=["markdown-style"])
|
| 70 |
|
| 71 |
image_input = gr.Image(label="Upload Image", type="pil")
|
| 72 |
|
|
|
|
| 74 |
with gr.TabItem("Grayscale", elem_classes="tab-button"):
|
| 75 |
with gr.Row():
|
| 76 |
with gr.Column():
|
| 77 |
+
gr.Markdown("Convert the image to grayscale.", elem_classes=["input-label"])
|
| 78 |
grayscale_button = gr.Button("Apply Grayscale", elem_classes="btn-primary")
|
| 79 |
with gr.Column():
|
| 80 |
grayscale_output = gr.Image(label="Grayscale Result")
|
|
|
|
| 83 |
with gr.TabItem("Canny Edge Detection", elem_classes="tab-button"):
|
| 84 |
with gr.Row():
|
| 85 |
with gr.Column():
|
| 86 |
+
gr.Markdown("Detect edges with adjustable thresholds.", elem_classes=["input-label"])
|
| 87 |
canny_t1 = gr.Slider(0, 500, value=100, step=10, label="Threshold 1")
|
| 88 |
canny_t2 = gr.Slider(0, 500, value=200, step=10, label="Threshold 2")
|
| 89 |
canny_button = gr.Button("Apply Canny", elem_classes="btn-primary")
|
|
|
|
| 94 |
with gr.TabItem("Gaussian Blur", elem_classes="tab-button"):
|
| 95 |
with gr.Row():
|
| 96 |
with gr.Column():
|
| 97 |
+
gr.Markdown("Apply Gaussian blur with adjustable kernel size.", elem_classes=["input-label"])
|
| 98 |
blur_kernel = gr.Slider(3, 21, value=5, step=2, label="Kernel Size")
|
| 99 |
blur_button = gr.Button("Apply Blur", elem_classes="btn-primary")
|
| 100 |
with gr.Column():
|
|
|
|
| 104 |
with gr.TabItem("Face Detection", elem_classes="tab-button"):
|
| 105 |
with gr.Row():
|
| 106 |
with gr.Column():
|
| 107 |
+
gr.Markdown("Detect faces using Haar Cascade.", elem_classes=["input-label"])
|
| 108 |
face_button = gr.Button("Detect Faces", elem_classes="btn-primary")
|
| 109 |
with gr.Column():
|
| 110 |
face_output = gr.Image(label="Faces Detected")
|
|
|
|
| 113 |
with gr.TabItem("Color Space Conversion", elem_classes="tab-button"):
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column():
|
| 116 |
+
gr.Markdown("Convert between RGB, HSV, and LAB color spaces.", elem_classes=["input-label"])
|
| 117 |
color_space = gr.Dropdown(choices=["RGB", "HSV", "LAB"], label="Color Space", value="RGB")
|
| 118 |
color_button = gr.Button("Apply Conversion", elem_classes="btn-primary")
|
| 119 |
with gr.Column():
|