selfitcamera commited on
Commit
94cf8d7
·
1 Parent(s): d21b31a
Files changed (1) hide show
  1. app.py +32 -51
app.py CHANGED
@@ -8,6 +8,9 @@ import json
8
  from util import process_image_edit, download_and_check_result_nsfw, GoodWebsiteUrl
9
  from nfsw import NSFWDetector
10
 
 
 
 
11
  # i18n
12
  def load_translations():
13
  translations = {}
@@ -541,7 +544,7 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
541
  if current_phase == 'blocked':
542
  # Generate blocked limit button with different URL for restricted countries
543
  if is_restricted or lang in ["hi", "ru", "zh"]:
544
- blocked_url = GoodWebsiteUrl
545
  else:
546
  blocked_url = 'https://omnicreator.net/#generator'
547
 
@@ -579,7 +582,7 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
579
  wait_minutes_int = int(wait_minutes) + 1
580
  # Generate rate limit button with different URL for restricted countries
581
  if is_restricted or lang in ["hi", "ru", "zh"]:
582
- rate_limit_url = GoodWebsiteUrl
583
  else:
584
  rate_limit_url = 'https://omnicreator.net/#generator'
585
 
@@ -741,7 +744,7 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
741
 
742
  # Generate NSFW button for blurred content with different URL for restricted countries
743
  if is_restricted or lang in ["hi", "ru", "zh"]:
744
- nsfw_url = GoodWebsiteUrl
745
  else:
746
  nsfw_url = 'https://omnicreator.net/#generator'
747
 
@@ -989,6 +992,7 @@ def create_app():
989
 
990
  with gr.Row(elem_classes=["news-banner-row"]):
991
  with gr.Column(scale=1, min_width=400):
 
992
  news_banner = gr.HTML(f"""
993
  <style>
994
  @keyframes breathe {{
@@ -1034,7 +1038,7 @@ def create_app():
1034
  </a>
1035
  </span>
1036
  </div>
1037
- """)
1038
 
1039
  with gr.Column(scale=0, min_width=160, elem_classes=["banner-lang-selector"]):
1040
  lang_dropdown = gr.Dropdown(
@@ -1356,53 +1360,30 @@ def create_app():
1356
  ]
1357
 
1358
  def update_ui_lang(lang):
1359
- if lang in ["hi", "ru", "zh"]:
1360
- return {
1361
- header_title: gr.update(value=f"""
1362
- <div style="text-align: center; margin: 20px auto 10px auto; max-width: 800px;">
1363
- <h1 style="color: #2c3e50; margin: 0; font-size: 3.5em; font-weight: 800; letter-spacing: 3px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1);">
1364
- {t('header_title', lang)}
1365
- </h1>
1366
- </div>"""),
1367
- }
1368
- else:
1369
- return {
1370
- header_title: gr.update(value=f"""
1371
- <div style="text-align: center; margin: 20px auto 10px auto; max-width: 800px;">
1372
- <h1 style="color: #2c3e50; margin: 0; font-size: 3.5em; font-weight: 800; letter-spacing: 3px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1);">
1373
- {t('header_title', lang)}
1374
- </h1>
1375
- </div>"""),
1376
- news_banner: gr.update(value=f"""
1377
- <style>
1378
- @keyframes breathe {{ 0%, 100% {{ transform: scale(1); }} 50% {{ transform: scale(1.02); }} }}
1379
- .breathing-banner {{ animation: breathe 3s ease-in-out infinite; }}
1380
- </style>
1381
- <div class="breathing-banner" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); margin: 5px auto 5px auto; padding: 6px 40px; border-radius: 20px; max-width: 800px; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); text-align: center;">
1382
- <span style="color: white; font-weight: 600; font-size: 1.0em;">
1383
- 🎉 NEW:
1384
- <a href="https://huggingface.co/spaces/Selfit/Multi-Image-Edit" target="_blank" style="color: white; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.5); transition: all 0.3s ease; margin: 0 8px;" onmouseover="this.style.borderBottom='1px solid white'" onmouseout="this.style.borderBottom='1px solid rgba(255,255,255,0.5)'">
1385
- Multi-Image-Edit
1386
- </a>
1387
- |
1388
- <a href="https://huggingface.co/spaces/Selfit/Text-to-Image-Pro" target="_blank" style="color: white; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.5); transition: all 0.3s ease; margin: 0 8px;" onmouseover="this.style.borderBottom='1px solid white'" onmouseout="this.style.borderBottom='1px solid rgba(255,255,255,0.5)'">
1389
- Text-to-Image
1390
- </a>
1391
- </span>
1392
- </div>"""),
1393
- global_tab: gr.update(label=t("global_editor_tab", lang)),
1394
- upload_image_header: gr.update(value=t("upload_image_header", lang)),
1395
- input_image: gr.update(label=t("upload_image_label", lang)),
1396
- editing_instructions_header: gr.update(value=t("editing_instructions_header", lang)),
1397
- prompt_input: gr.update(label=t("prompt_input_label", lang), placeholder=t("prompt_input_placeholder", lang)),
1398
- edit_button: gr.update(value=t("start_editing_button", lang)),
1399
- editing_result_header: gr.update(value=t("editing_result_header", lang)),
1400
- output_image: gr.update(label=t("output_image_label", lang)),
1401
- use_as_input_btn: gr.update(value=t("use_as_input_button", lang)),
1402
- status_output: gr.update(label=t("status_output_label", lang)),
1403
- prompt_examples_header: gr.update(value=t("prompt_examples_header", lang)),
1404
- seo_html: gr.update(value=get_seo_html(lang)),
1405
- }
1406
 
1407
  def on_lang_change(lang):
1408
  return lang, *update_ui_lang(lang).values()
 
8
  from util import process_image_edit, download_and_check_result_nsfw, GoodWebsiteUrl
9
  from nfsw import NSFWDetector
10
 
11
+ # Google Gemini URL for restricted languages
12
+ GOOGLE_GEMINI_URL = "https://aistudio.google.com/models/gemini-2-5-flash-image"
13
+
14
  # i18n
15
  def load_translations():
16
  translations = {}
 
544
  if current_phase == 'blocked':
545
  # Generate blocked limit button with different URL for restricted countries
546
  if is_restricted or lang in ["hi", "ru", "zh"]:
547
+ blocked_url = GOOGLE_GEMINI_URL
548
  else:
549
  blocked_url = 'https://omnicreator.net/#generator'
550
 
 
582
  wait_minutes_int = int(wait_minutes) + 1
583
  # Generate rate limit button with different URL for restricted countries
584
  if is_restricted or lang in ["hi", "ru", "zh"]:
585
+ rate_limit_url = GOOGLE_GEMINI_URL
586
  else:
587
  rate_limit_url = 'https://omnicreator.net/#generator'
588
 
 
744
 
745
  # Generate NSFW button for blurred content with different URL for restricted countries
746
  if is_restricted or lang in ["hi", "ru", "zh"]:
747
+ nsfw_url = GOOGLE_GEMINI_URL
748
  else:
749
  nsfw_url = 'https://omnicreator.net/#generator'
750
 
 
992
 
993
  with gr.Row(elem_classes=["news-banner-row"]):
994
  with gr.Column(scale=1, min_width=400):
995
+ # Banner is initially visible (will be hidden for zh/hi/ru languages on load)
996
  news_banner = gr.HTML(f"""
997
  <style>
998
  @keyframes breathe {{
 
1038
  </a>
1039
  </span>
1040
  </div>
1041
+ """, visible=True)
1042
 
1043
  with gr.Column(scale=0, min_width=160, elem_classes=["banner-lang-selector"]):
1044
  lang_dropdown = gr.Dropdown(
 
1360
  ]
1361
 
1362
  def update_ui_lang(lang):
1363
+ # Hide banner for zh, hi, ru languages
1364
+ show_banner = lang not in ["zh", "hi", "ru"]
1365
+
1366
+ return {
1367
+ header_title: gr.update(value=f"""
1368
+ <div style="text-align: center; margin: 20px auto 10px auto; max-width: 800px;">
1369
+ <h1 style="color: #2c3e50; margin: 0; font-size: 3.5em; font-weight: 800; letter-spacing: 3px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1);">
1370
+ {t('header_title', lang)}
1371
+ </h1>
1372
+ </div>"""),
1373
+ news_banner: gr.update(visible=show_banner),
1374
+ global_tab: gr.update(label=t("global_editor_tab", lang)),
1375
+ upload_image_header: gr.update(value=t("upload_image_header", lang)),
1376
+ input_image: gr.update(label=t("upload_image_label", lang)),
1377
+ editing_instructions_header: gr.update(value=t("editing_instructions_header", lang)),
1378
+ prompt_input: gr.update(label=t("prompt_input_label", lang), placeholder=t("prompt_input_placeholder", lang)),
1379
+ edit_button: gr.update(value=t("start_editing_button", lang)),
1380
+ editing_result_header: gr.update(value=t("editing_result_header", lang)),
1381
+ output_image: gr.update(label=t("output_image_label", lang)),
1382
+ use_as_input_btn: gr.update(value=t("use_as_input_button", lang)),
1383
+ status_output: gr.update(label=t("status_output_label", lang)),
1384
+ prompt_examples_header: gr.update(value=t("prompt_examples_header", lang)),
1385
+ seo_html: gr.update(value=get_seo_html(lang)),
1386
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1387
 
1388
  def on_lang_change(lang):
1389
  return lang, *update_ui_lang(lang).values()