Spaces:
Running
Running
Commit
Β·
a0567be
1
Parent(s):
68e04c1
init
Browse files
app.py
CHANGED
|
@@ -212,14 +212,58 @@ def edit_image_interface(input_image, prompt, request: gr.Request, progress=gr.P
|
|
| 212 |
|
| 213 |
# Check if completely blocked
|
| 214 |
if current_phase == 'blocked':
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
# Check rate limit (applies to rate_limit phases)
|
| 218 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
| 219 |
is_limited, wait_minutes, window_count = check_rate_limit_for_phase(client_ip, current_phase)
|
| 220 |
if is_limited:
|
| 221 |
wait_minutes_int = int(wait_minutes) + 1
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
# Handle NSFW detection based on phase
|
| 225 |
is_nsfw_task = False # Track if this task involves NSFW content
|
|
@@ -304,6 +348,30 @@ def edit_image_interface(input_image, prompt, request: gr.Request, progress=gr.P
|
|
| 304 |
# Blur failed, return original URL with warning
|
| 305 |
final_result = result_url
|
| 306 |
final_message = f"β οΈ NSFW content detected, but content filter failed. Please visit https://omnicreator.net/#generator for better experience"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
else:
|
| 308 |
final_result = result_url
|
| 309 |
final_message = "β
" + message
|
|
@@ -411,14 +479,58 @@ def local_edit_interface(image_dict, prompt, request: gr.Request, progress=gr.Pr
|
|
| 411 |
|
| 412 |
# Check if completely blocked
|
| 413 |
if current_phase == 'blocked':
|
| 414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
|
| 416 |
# Check rate limit (applies to rate_limit phases)
|
| 417 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
| 418 |
is_limited, wait_minutes, window_count = check_rate_limit_for_phase(client_ip, current_phase)
|
| 419 |
if is_limited:
|
| 420 |
wait_minutes_int = int(wait_minutes) + 1
|
| 421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
|
| 423 |
# Handle NSFW detection based on phase
|
| 424 |
is_nsfw_task = False # Track if this task involves NSFW content
|
|
@@ -503,6 +615,30 @@ def local_edit_interface(image_dict, prompt, request: gr.Request, progress=gr.Pr
|
|
| 503 |
# Blur failed, return original URL with warning
|
| 504 |
final_result = result_url
|
| 505 |
final_message = f"β οΈ NSFW content detected, but content filter failed. Please visit https://omnicreator.net/#generator for better experience"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
else:
|
| 507 |
final_result = result_url
|
| 508 |
final_message = "β
" + message
|
|
|
|
| 212 |
|
| 213 |
# Check if completely blocked
|
| 214 |
if current_phase == 'blocked':
|
| 215 |
+
# Generate blocked limit button
|
| 216 |
+
blocked_button_html = f"""
|
| 217 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 218 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 219 |
+
display: inline-flex;
|
| 220 |
+
align-items: center;
|
| 221 |
+
justify-content: center;
|
| 222 |
+
padding: 16px 32px;
|
| 223 |
+
background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
|
| 224 |
+
color: white;
|
| 225 |
+
text-decoration: none;
|
| 226 |
+
border-radius: 12px;
|
| 227 |
+
font-weight: 600;
|
| 228 |
+
font-size: 16px;
|
| 229 |
+
text-align: center;
|
| 230 |
+
min-width: 200px;
|
| 231 |
+
box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
|
| 232 |
+
transition: all 0.3s ease;
|
| 233 |
+
border: none;
|
| 234 |
+
'>π Unlimited Generation</a>
|
| 235 |
+
</div>
|
| 236 |
+
"""
|
| 237 |
+
return None, f"β You have reached Hugging Face's free generation limit. Please visit https://omnicreator.net/#generator for unlimited generation", gr.update(value=blocked_button_html, visible=True)
|
| 238 |
|
| 239 |
# Check rate limit (applies to rate_limit phases)
|
| 240 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
| 241 |
is_limited, wait_minutes, window_count = check_rate_limit_for_phase(client_ip, current_phase)
|
| 242 |
if is_limited:
|
| 243 |
wait_minutes_int = int(wait_minutes) + 1
|
| 244 |
+
# Generate rate limit button
|
| 245 |
+
rate_limit_button_html = f"""
|
| 246 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 247 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 248 |
+
display: inline-flex;
|
| 249 |
+
align-items: center;
|
| 250 |
+
justify-content: center;
|
| 251 |
+
padding: 16px 32px;
|
| 252 |
+
background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
|
| 253 |
+
color: white;
|
| 254 |
+
text-decoration: none;
|
| 255 |
+
border-radius: 12px;
|
| 256 |
+
font-weight: 600;
|
| 257 |
+
font-size: 16px;
|
| 258 |
+
text-align: center;
|
| 259 |
+
min-width: 200px;
|
| 260 |
+
box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
|
| 261 |
+
transition: all 0.3s ease;
|
| 262 |
+
border: none;
|
| 263 |
+
'>β° Skip Wait - Unlimited Generation</a>
|
| 264 |
+
</div>
|
| 265 |
+
"""
|
| 266 |
+
return None, f"β You have reached Hugging Face's free generation limit. Please visit https://omnicreator.net/#generator for unlimited generation, or wait {wait_minutes_int} minutes before generating again", gr.update(value=rate_limit_button_html, visible=True)
|
| 267 |
|
| 268 |
# Handle NSFW detection based on phase
|
| 269 |
is_nsfw_task = False # Track if this task involves NSFW content
|
|
|
|
| 348 |
# Blur failed, return original URL with warning
|
| 349 |
final_result = result_url
|
| 350 |
final_message = f"β οΈ NSFW content detected, but content filter failed. Please visit https://omnicreator.net/#generator for better experience"
|
| 351 |
+
|
| 352 |
+
# Generate NSFW button for blurred content
|
| 353 |
+
nsfw_action_buttons_html = f"""
|
| 354 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 355 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 356 |
+
display: inline-flex;
|
| 357 |
+
align-items: center;
|
| 358 |
+
justify-content: center;
|
| 359 |
+
padding: 16px 32px;
|
| 360 |
+
background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
|
| 361 |
+
color: white;
|
| 362 |
+
text-decoration: none;
|
| 363 |
+
border-radius: 12px;
|
| 364 |
+
font-weight: 600;
|
| 365 |
+
font-size: 16px;
|
| 366 |
+
text-align: center;
|
| 367 |
+
min-width: 200px;
|
| 368 |
+
box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
|
| 369 |
+
transition: all 0.3s ease;
|
| 370 |
+
border: none;
|
| 371 |
+
'>π₯ Unlimited NSFW Generation</a>
|
| 372 |
+
</div>
|
| 373 |
+
"""
|
| 374 |
+
return final_result, final_message, gr.update(value=nsfw_action_buttons_html, visible=True)
|
| 375 |
else:
|
| 376 |
final_result = result_url
|
| 377 |
final_message = "β
" + message
|
|
|
|
| 479 |
|
| 480 |
# Check if completely blocked
|
| 481 |
if current_phase == 'blocked':
|
| 482 |
+
# Generate blocked limit button
|
| 483 |
+
blocked_button_html = f"""
|
| 484 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 485 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 486 |
+
display: inline-flex;
|
| 487 |
+
align-items: center;
|
| 488 |
+
justify-content: center;
|
| 489 |
+
padding: 16px 32px;
|
| 490 |
+
background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
|
| 491 |
+
color: white;
|
| 492 |
+
text-decoration: none;
|
| 493 |
+
border-radius: 12px;
|
| 494 |
+
font-weight: 600;
|
| 495 |
+
font-size: 16px;
|
| 496 |
+
text-align: center;
|
| 497 |
+
min-width: 200px;
|
| 498 |
+
box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
|
| 499 |
+
transition: all 0.3s ease;
|
| 500 |
+
border: none;
|
| 501 |
+
'>π Unlimited Generation</a>
|
| 502 |
+
</div>
|
| 503 |
+
"""
|
| 504 |
+
return None, f"β You have reached Hugging Face's free generation limit. Please visit https://omnicreator.net/#generator for unlimited generation", gr.update(value=blocked_button_html, visible=True)
|
| 505 |
|
| 506 |
# Check rate limit (applies to rate_limit phases)
|
| 507 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
| 508 |
is_limited, wait_minutes, window_count = check_rate_limit_for_phase(client_ip, current_phase)
|
| 509 |
if is_limited:
|
| 510 |
wait_minutes_int = int(wait_minutes) + 1
|
| 511 |
+
# Generate rate limit button
|
| 512 |
+
rate_limit_button_html = f"""
|
| 513 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 514 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 515 |
+
display: inline-flex;
|
| 516 |
+
align-items: center;
|
| 517 |
+
justify-content: center;
|
| 518 |
+
padding: 16px 32px;
|
| 519 |
+
background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
|
| 520 |
+
color: white;
|
| 521 |
+
text-decoration: none;
|
| 522 |
+
border-radius: 12px;
|
| 523 |
+
font-weight: 600;
|
| 524 |
+
font-size: 16px;
|
| 525 |
+
text-align: center;
|
| 526 |
+
min-width: 200px;
|
| 527 |
+
box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
|
| 528 |
+
transition: all 0.3s ease;
|
| 529 |
+
border: none;
|
| 530 |
+
'>β° Skip Wait - Unlimited Generation</a>
|
| 531 |
+
</div>
|
| 532 |
+
"""
|
| 533 |
+
return None, f"β You have reached Hugging Face's free generation limit. Please visit https://omnicreator.net/#generator for unlimited generation, or wait {wait_minutes_int} minutes before generating again", gr.update(value=rate_limit_button_html, visible=True)
|
| 534 |
|
| 535 |
# Handle NSFW detection based on phase
|
| 536 |
is_nsfw_task = False # Track if this task involves NSFW content
|
|
|
|
| 615 |
# Blur failed, return original URL with warning
|
| 616 |
final_result = result_url
|
| 617 |
final_message = f"β οΈ NSFW content detected, but content filter failed. Please visit https://omnicreator.net/#generator for better experience"
|
| 618 |
+
|
| 619 |
+
# Generate NSFW button for blurred content
|
| 620 |
+
nsfw_action_buttons_html = f"""
|
| 621 |
+
<div style='display: flex; justify-content: center; gap: 15px; margin: 10px 0 5px 0; padding: 0px;'>
|
| 622 |
+
<a href='https://omnicreator.net/#generator' target='_blank' style='
|
| 623 |
+
display: inline-flex;
|
| 624 |
+
align-items: center;
|
| 625 |
+
justify-content: center;
|
| 626 |
+
padding: 16px 32px;
|
| 627 |
+
background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
|
| 628 |
+
color: white;
|
| 629 |
+
text-decoration: none;
|
| 630 |
+
border-radius: 12px;
|
| 631 |
+
font-weight: 600;
|
| 632 |
+
font-size: 16px;
|
| 633 |
+
text-align: center;
|
| 634 |
+
min-width: 200px;
|
| 635 |
+
box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
|
| 636 |
+
transition: all 0.3s ease;
|
| 637 |
+
border: none;
|
| 638 |
+
'>π₯ Unlimited NSFW Generation</a>
|
| 639 |
+
</div>
|
| 640 |
+
"""
|
| 641 |
+
return final_result, final_message, gr.update(value=nsfw_action_buttons_html, visible=True)
|
| 642 |
else:
|
| 643 |
final_result = result_url
|
| 644 |
final_message = "β
" + message
|