Spaces:
Running
on
Zero
Running
on
Zero
gradio
Browse files
app.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
# TODO: UI/UX: Better display on mobile so folks don't miss the final output
|
| 2 |
-
# TODO: Upgrade gradio
|
| 3 |
-
|
| 4 |
import logging
|
| 5 |
import os
|
| 6 |
import sys
|
|
@@ -145,9 +142,6 @@ def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
|
|
| 145 |
|
| 146 |
Returns:
|
| 147 |
Any: The value at the given index.
|
| 148 |
-
|
| 149 |
-
Raises:
|
| 150 |
-
IndexError: If the index is out of bounds for the object and the object is not a mapping.
|
| 151 |
"""
|
| 152 |
try:
|
| 153 |
return obj[index]
|
|
@@ -273,51 +267,50 @@ def advance_blur(input_image):
|
|
| 273 |
|
| 274 |
|
| 275 |
if __name__ == "__main__":
|
| 276 |
-
#
|
| 277 |
css_code = """
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
-
/*
|
| 284 |
-
@media (max-width: 768px) {
|
| 285 |
#fixed-image-size {
|
| 286 |
-
max-width:
|
| 287 |
-
max-height:
|
| 288 |
}
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
justify-content: left;
|
| 297 |
-
margin-left: 0;
|
| 298 |
-
margin-right: 0;
|
| 299 |
-
padding-left: 0;
|
| 300 |
-
padding-right: 0;
|
| 301 |
-
overflow-x: auto;
|
| 302 |
-
gap: 20px;
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
.example-image {
|
| 306 |
-
display: flex;
|
| 307 |
-
flex-direction: column;
|
| 308 |
-
align-items: start;
|
| 309 |
-
margin-right: 20px;
|
| 310 |
-
max-width: 140px !important; /* fix the width of image */
|
| 311 |
-
max-height: 140px !important; /* fix the height of image */
|
| 312 |
-
}
|
| 313 |
-
"""
|
| 314 |
-
with gr.Blocks(css=css_code, theme=gr.themes.Base()) as app:
|
| 315 |
-
gr.Markdown( """
|
| 316 |
-
# 🥸 Advance Blur
|
| 317 |
|
| 318 |
-
|
| 319 |
-
|
| 320 |
|
|
|
|
| 321 |
with gr.Row(elem_id="example-images"):
|
| 322 |
with gr.Column(elem_classes=["example-image"]):
|
| 323 |
gr.Image(
|
|
@@ -337,18 +330,16 @@ if __name__ == "__main__":
|
|
| 337 |
with gr.Accordion("More info", open=False):
|
| 338 |
gr.Markdown(
|
| 339 |
"""
|
| 340 |
-
**Advance Blur** uses a sophisticated technique called "Vance Blurring" to anonymize images
|
| 341 |
|
| 342 |
**Features:**
|
| 343 |
-
- **Replaces up to 100 faces
|
| 344 |
-
- **Removes identifying metadata
|
| 345 |
-
- **Safe and secure:** All uploaded images
|
| 346 |
|
| 347 |
**Disclaimer:**
|
| 348 |
-
This
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
_No sofas, couches, chaises, or other living-room furniture were harmed in the production of Advance Blur._
|
| 352 |
"""
|
| 353 |
)
|
| 354 |
|
|
@@ -371,6 +362,6 @@ if __name__ == "__main__":
|
|
| 371 |
|
| 372 |
# Trigger your blur function
|
| 373 |
submit_btn.click(fn=advance_blur, inputs=[input_image], outputs=[output_image])
|
| 374 |
-
# Add a Gradio Examples section to let users see a sample run
|
| 375 |
|
|
|
|
| 376 |
app.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
import sys
|
|
|
|
| 142 |
|
| 143 |
Returns:
|
| 144 |
Any: The value at the given index.
|
|
|
|
|
|
|
|
|
|
| 145 |
"""
|
| 146 |
try:
|
| 147 |
return obj[index]
|
|
|
|
| 267 |
|
| 268 |
|
| 269 |
if __name__ == "__main__":
|
| 270 |
+
# Updated, more flexible CSS
|
| 271 |
css_code = """
|
| 272 |
+
/* Container for side-by-side example images */
|
| 273 |
+
#example-images {
|
| 274 |
+
display: flex;
|
| 275 |
+
gap: 20px;
|
| 276 |
+
flex-wrap: wrap; /* Wrap if not enough space */
|
| 277 |
+
justify-content: center; /* Center them in their container */
|
| 278 |
+
margin-bottom: 1rem;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/* Each example image column */
|
| 282 |
+
.example-image img {
|
| 283 |
+
width: 100%;
|
| 284 |
+
height: auto;
|
| 285 |
+
max-width: 300px; /* You can adjust this for larger previews */
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/* If you REALLY want them side-by-side on mobile,
|
| 289 |
+
let them scroll horizontally instead of wrapping. */
|
| 290 |
+
@media (max-width: 768px) {
|
| 291 |
+
#example-images {
|
| 292 |
+
overflow-x: auto;
|
| 293 |
+
flex-wrap: nowrap; /* Force side-by-side with horizontal scroll */
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
|
| 297 |
+
/* Fix the main input/output image sizes for uniform display */
|
|
|
|
| 298 |
#fixed-image-size {
|
| 299 |
+
max-width: 600px !important;
|
| 300 |
+
max-height: 600px !important;
|
| 301 |
}
|
| 302 |
+
@media (max-width: 768px) {
|
| 303 |
+
#fixed-image-size {
|
| 304 |
+
max-width: 320px !important;
|
| 305 |
+
max-height: 320px !important;
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
+
with gr.Blocks(css=css_code, theme=gr.themes.Base()) as app:
|
| 311 |
+
gr.Markdown("# 🥸 Advance Blur")
|
| 312 |
|
| 313 |
+
# Side-by-side examples
|
| 314 |
with gr.Row(elem_id="example-images"):
|
| 315 |
with gr.Column(elem_classes=["example-image"]):
|
| 316 |
gr.Image(
|
|
|
|
| 330 |
with gr.Accordion("More info", open=False):
|
| 331 |
gr.Markdown(
|
| 332 |
"""
|
| 333 |
+
**Advance Blur** uses a sophisticated technique called "Vance Blurring" to anonymize images!
|
| 334 |
|
| 335 |
**Features:**
|
| 336 |
+
- **Replaces up to 100 faces** with the face of the ideal American male!
|
| 337 |
+
- **Removes identifying metadata** (EXIF, IPTC, and XMP).
|
| 338 |
+
- **Safe and secure:** All uploaded images are deleted after processing.
|
| 339 |
|
| 340 |
**Disclaimer:**
|
| 341 |
+
This is for entertainment only. Any resemblance to actual persons is purely coincidental, comedic,
|
| 342 |
+
karmic, or parody.
|
|
|
|
|
|
|
| 343 |
"""
|
| 344 |
)
|
| 345 |
|
|
|
|
| 362 |
|
| 363 |
# Trigger your blur function
|
| 364 |
submit_btn.click(fn=advance_blur, inputs=[input_image], outputs=[output_image])
|
|
|
|
| 365 |
|
| 366 |
+
# Launch the app
|
| 367 |
app.launch(share=True)
|