Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,6 +38,9 @@ theme = gr.themes.Soft(
|
|
| 38 |
)
|
| 39 |
#----------End of theme----------
|
| 40 |
|
|
|
|
|
|
|
|
|
|
| 41 |
def basic_filter(image, filter_type):
|
| 42 |
"""Apply basic image filters"""
|
| 43 |
if filter_type == "Gray Toning":
|
|
@@ -88,13 +91,7 @@ def classic_filter(image, filter_type):
|
|
| 88 |
|
| 89 |
def creative_filter(image, filter_type):
|
| 90 |
"""Creative and unusual image filters"""
|
| 91 |
-
if filter_type == "
|
| 92 |
-
h, w = image.shape[:2]
|
| 93 |
-
pixsel_size = 20
|
| 94 |
-
small = cv2.resize(image, (w//piksel_size, h//pixsel_size))
|
| 95 |
-
return cv2.resize(small, (w, h), interpolation=cv2.INTER_NEAREST)
|
| 96 |
-
|
| 97 |
-
elif filter_type == "Mosaic Effect":
|
| 98 |
h, w = image.shape[:2]
|
| 99 |
mosaic_size = 30
|
| 100 |
for i in range(0, h, mosaic_size):
|
|
@@ -246,7 +243,7 @@ def image_processing(image, filter_type):
|
|
| 246 |
# Process by filter categories
|
| 247 |
basic_filter_list = ["Grey Toning", "Sepia", "X-ray", "Blur"]
|
| 248 |
Classic_filters_list = ["Charcoal Effect", "Sharpen", "Relief", "Edge Detection"]
|
| 249 |
-
creative_filters_list = ["
|
| 250 |
special_effects_list = ["Matrix Effect", "Wave Effect", "Time Stamp," "Glitch Effect"]
|
| 251 |
artistic_filters_listesi = ["Pop Art", "Oil Paint", "Cartoon"]
|
| 252 |
atmospheric_filters_list = ["Autumn", "Nostalgia", "Increase Brightness"]
|
|
@@ -271,74 +268,45 @@ def image_processing(image, filter_type):
|
|
| 271 |
# Gradio interface
|
| 272 |
with gr.Blocks(theme=theme) as app:
|
| 273 |
gr.Markdown("Image Filtering Studio")
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
- **Sepia**: Adds warm brown tones that give the photo an old photo vibe
|
| 309 |
-
- **X-ray**: Creates the effect of an X-ray scan by adding backlighting to the image
|
| 310 |
-
- **Blur": It reduces details by creating a soft blur in the image.
|
| 311 |
-
|
| 312 |
-
#### Classic Filters List
|
| 313 |
-
- **Charcoal Effect**: It makes the image look like a charcoal drawing
|
| 314 |
-
- **Sharpen**: Highlights the details in the image
|
| 315 |
-
- **Emboss**: Adds embossing and depth effect to the image
|
| 316 |
-
- **Bulk Detection: Emphasizes edge lines in the image
|
| 317 |
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
#### Special Effects
|
| 325 |
-
- **Matrix Effect**: Matrix movie effect
|
| 326 |
-
- **Wave Effect**: Adds a water wave-like twisted degradation to the image, creating a feeling of ripple
|
| 327 |
-
- **Time Stamp***: Adds the date and time of taking the photo on it gives a nostalgic atmosphere
|
| 328 |
-
- **Glitch Effect***: Adding digital distortions, adds a retro style error effect to the photo
|
| 329 |
-
|
| 330 |
-
#### Artistic Filters
|
| 331 |
-
- **Pop Art**: With vivid and contrasted colors, Andy Warhol-style creates iconic pop-art effect
|
| 332 |
-
- **Oil Paint***: Simulates brush strokes, giving the image the appearance of oil painting
|
| 333 |
-
- **Texture Effect***: Adding surface texture to the image gives a touching depth and a vial of artwork
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
""")
|
| 337 |
|
| 338 |
-
submit_button.click(
|
| 339 |
-
image_processing,
|
| 340 |
-
inputs=[image_input, filter_type],
|
| 341 |
-
outputs=image_output
|
| 342 |
-
)
|
| 343 |
-
|
| 344 |
app.launch(share=True)
|
|
|
|
| 38 |
)
|
| 39 |
#----------End of theme----------
|
| 40 |
|
| 41 |
+
def flip_image(x):
|
| 42 |
+
return np.fliplr(x)
|
| 43 |
+
|
| 44 |
def basic_filter(image, filter_type):
|
| 45 |
"""Apply basic image filters"""
|
| 46 |
if filter_type == "Gray Toning":
|
|
|
|
| 91 |
|
| 92 |
def creative_filter(image, filter_type):
|
| 93 |
"""Creative and unusual image filters"""
|
| 94 |
+
if filter_type == "Mosaic Effect":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
h, w = image.shape[:2]
|
| 96 |
mosaic_size = 30
|
| 97 |
for i in range(0, h, mosaic_size):
|
|
|
|
| 243 |
# Process by filter categories
|
| 244 |
basic_filter_list = ["Grey Toning", "Sepia", "X-ray", "Blur"]
|
| 245 |
Classic_filters_list = ["Charcoal Effect", "Sharpen", "Relief", "Edge Detection"]
|
| 246 |
+
creative_filters_list = ["Mosaic Effect", "Rainbow", "Night Vision"]
|
| 247 |
special_effects_list = ["Matrix Effect", "Wave Effect", "Time Stamp," "Glitch Effect"]
|
| 248 |
artistic_filters_listesi = ["Pop Art", "Oil Paint", "Cartoon"]
|
| 249 |
atmospheric_filters_list = ["Autumn", "Nostalgia", "Increase Brightness"]
|
|
|
|
| 268 |
# Gradio interface
|
| 269 |
with gr.Blocks(theme=theme) as app:
|
| 270 |
gr.Markdown("Image Filtering Studio")
|
| 271 |
+
with gr.Tab("Flip Image"):
|
| 272 |
+
with gr.Row():
|
| 273 |
+
image_input = gr.Image()
|
| 274 |
+
image_output = gr.Image(format="png")
|
| 275 |
+
with gr.Row():
|
| 276 |
+
image_button = gr.Button("Run", variant='primary')
|
| 277 |
+
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
| 278 |
+
with gr.Tab("Image Filters"):
|
| 279 |
+
with gr.Row():
|
| 280 |
+
with gr.Column():
|
| 281 |
+
image_input = gr.Image(type="numpy", label="📸 Upload Photos")
|
| 282 |
+
with gr.Accordion("ℹ️ Filter Categories", open=True):
|
| 283 |
+
filter_type = gr.Radio(
|
| 284 |
+
[
|
| 285 |
+
# Basic Filters
|
| 286 |
+
"Grey Toning", "Sepia", "X-ray", "Blur",
|
| 287 |
+
# Classic_filters_list
|
| 288 |
+
"Charcoal Effect", "Sharpen", "Relief", "Edge Detection",
|
| 289 |
+
# Creative Filters
|
| 290 |
+
"Mosaic Effect", "Rainbow", "Night Vision",
|
| 291 |
+
# Special Effects
|
| 292 |
+
"Matrix Effect", "Wave Effect", "Time Stamp", "Glitch Effect",
|
| 293 |
+
# Artistic Filters
|
| 294 |
+
"Pop Art", "Oil Paint", "Cartoon",
|
| 295 |
+
#Atmospheric Filters
|
| 296 |
+
"Autumn", "Nostalgia", "Increasing Shiny"
|
| 297 |
+
],
|
| 298 |
+
label="🎭 Select Filter",
|
| 299 |
+
info="Choose the magic effect you want"
|
| 300 |
+
)
|
| 301 |
+
submit_button = gr.Button("✨ Apply Filter", variant="primary")
|
| 302 |
+
|
| 303 |
+
with gr.Column():
|
| 304 |
+
image_output = gr.Image(label="🖼️ Filtered Photo")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
+
submit_button.click(
|
| 307 |
+
image_processing,
|
| 308 |
+
inputs=[image_input, filter_type],
|
| 309 |
+
outputs=image_output
|
| 310 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
app.launch(share=True)
|