local dev and multitab base
Browse files- .github/workflows/deploy.yml +0 -0
- app.py +53 -14
- dev.py +9 -0
.github/workflows/deploy.yml
DELETED
|
File without changes
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import numpy as np
|
|
| 3 |
import cv2
|
| 4 |
from sklearn.cluster import KMeans
|
| 5 |
from collections import Counter
|
|
|
|
| 6 |
|
| 7 |
def extract_palette(image, num_colors=5):
|
| 8 |
# Convert to LAB color space for better color perception
|
|
@@ -67,19 +68,57 @@ def visualize_palette(image, num_colors):
|
|
| 67 |
|
| 68 |
return output_path
|
| 69 |
|
| 70 |
-
# Gradio
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
gr.
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
# Launch the app
|
| 84 |
if __name__ == "__main__":
|
| 85 |
-
demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import cv2
|
| 4 |
from sklearn.cluster import KMeans
|
| 5 |
from collections import Counter
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
def extract_palette(image, num_colors=5):
|
| 9 |
# Convert to LAB color space for better color perception
|
|
|
|
| 68 |
|
| 69 |
return output_path
|
| 70 |
|
| 71 |
+
# Create the Gradio Blocks app with tabs
|
| 72 |
+
def create_demo():
|
| 73 |
+
with gr.Blocks(title="CV Tools", theme=gr.themes.Soft()) as demo:
|
| 74 |
+
gr.Markdown("# Computer Vision Tools")
|
| 75 |
+
|
| 76 |
+
with gr.Tabs():
|
| 77 |
+
# Tab 1: Color Palette Extractor
|
| 78 |
+
with gr.Tab("Color Palette"):
|
| 79 |
+
gr.Markdown("## Extract dominant colors from your image")
|
| 80 |
+
with gr.Row():
|
| 81 |
+
with gr.Column():
|
| 82 |
+
input_image = gr.Image(type="numpy", label="Input Image")
|
| 83 |
+
num_colors = gr.Slider(
|
| 84 |
+
minimum=2,
|
| 85 |
+
maximum=50,
|
| 86 |
+
step=1,
|
| 87 |
+
value=5,
|
| 88 |
+
label="Number of Colors"
|
| 89 |
+
)
|
| 90 |
+
extract_btn = gr.Button("Extract Palette", variant="primary")
|
| 91 |
+
|
| 92 |
+
with gr.Column():
|
| 93 |
+
output_palette = gr.Image(
|
| 94 |
+
type="filepath",
|
| 95 |
+
label="Color Palette"
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
extract_btn.click(
|
| 99 |
+
fn=visualize_palette,
|
| 100 |
+
inputs=[input_image, num_colors],
|
| 101 |
+
outputs=output_palette
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
# Tab 2: Image Filters (placeholder for your next feature)
|
| 105 |
+
with gr.Tab("Image Filters"):
|
| 106 |
+
gr.Markdown("## Image Filters (Coming Soon)")
|
| 107 |
+
# Add your image filters interface here
|
| 108 |
+
|
| 109 |
+
# Tab 3: Another CV feature (placeholder)
|
| 110 |
+
with gr.Tab("More Features"):
|
| 111 |
+
gr.Markdown("## More Features Coming Soon")
|
| 112 |
+
# Add more CV tools here
|
| 113 |
+
|
| 114 |
+
return demo
|
| 115 |
|
| 116 |
+
# Launch the app with auto-reloading in development
|
| 117 |
if __name__ == "__main__":
|
| 118 |
+
demo = create_demo()
|
| 119 |
+
demo.queue() # Enable queuing for better handling of simultaneous requests
|
| 120 |
+
demo.launch(
|
| 121 |
+
share=True, # Enable sharing
|
| 122 |
+
server_port=7860, # Specify port
|
| 123 |
+
server_name="0.0.0.0" # Listen on all interfaces
|
| 124 |
+
)
|
dev.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app import create_demo
|
| 2 |
+
|
| 3 |
+
if __name__ == "__main__":
|
| 4 |
+
demo = create_demo()
|
| 5 |
+
demo.queue()
|
| 6 |
+
demo.launch(
|
| 7 |
+
server_port=7860,
|
| 8 |
+
server_name="0.0.0.0"
|
| 9 |
+
)
|