Vector857 commited on
Commit
d67f5fb
Β·
verified Β·
1 Parent(s): 81baa68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -6,19 +6,6 @@ import random
6
  import numpy as np
7
  from typing import Iterable
8
 
9
- # Patch: HfFolder removed in huggingface_hub>=0.24 but needed by gradio 4.40
10
- import huggingface_hub as _hfh
11
- if not hasattr(_hfh, "HfFolder"):
12
- class _HfFolder:
13
- @staticmethod
14
- def get_token():
15
- return os.environ.get("HF_TOKEN", None)
16
- @staticmethod
17
- def save_token(token): pass
18
- @staticmethod
19
- def delete_token(): pass
20
- _hfh.HfFolder = _HfFolder
21
-
22
  import torch
23
  from PIL import Image
24
  import gradio as gr
@@ -286,8 +273,11 @@ def generate(
286
  prompt, neg_prompt, cfg, steps, selected_index,
287
  randomize_seed, seed, aspect, lora_scale, speed_mode,
288
  history_state,
 
289
  progress=gr.Progress(track_tqdm=True),
290
  ):
 
 
291
  if selected_index is None:
292
  raise gr.Error("Select a LoRA from the gallery first.")
293
  if not prompt.strip():
@@ -540,6 +530,10 @@ with gr.Blocks(theme=drex_theme, css=CSS, js=JS_INIT, delete_cache=(300, 300), t
540
  </div>
541
  """)
542
 
 
 
 
 
543
  # ── THEME BAR ──
544
  with gr.Row():
545
  theme_selector = gr.HTML("""
@@ -710,6 +704,7 @@ with gr.Blocks(theme=drex_theme, css=CSS, js=JS_INIT, delete_cache=(300, 300), t
710
  ],
711
  outputs=[result, seed, meta_panel, history_html, history_state],
712
  )
 
713
 
714
  custom_lora_input.input(
715
  add_custom_lora,
@@ -730,4 +725,4 @@ with gr.Blocks(theme=drex_theme, css=CSS, js=JS_INIT, delete_cache=(300, 300), t
730
  # ── LAUNCH ────────────────────────────────────────────────────────────────────
731
 
732
  app.queue()
733
- app.launch(show_error=True, share=False, server_name="0.0.0.0")
 
6
  import numpy as np
7
  from typing import Iterable
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import torch
10
  from PIL import Image
11
  import gradio as gr
 
273
  prompt, neg_prompt, cfg, steps, selected_index,
274
  randomize_seed, seed, aspect, lora_scale, speed_mode,
275
  history_state,
276
+ oauth_token: gr.OAuthToken | None = None,
277
  progress=gr.Progress(track_tqdm=True),
278
  ):
279
+ if oauth_token is None:
280
+ raise gr.Error("Please sign in with your HuggingFace account to generate images.")
281
  if selected_index is None:
282
  raise gr.Error("Select a LoRA from the gallery first.")
283
  if not prompt.strip():
 
530
  </div>
531
  """)
532
 
533
+ # ── LOGIN ──
534
+ with gr.Row():
535
+ gr.LoginButton(scale=0)
536
+
537
  # ── THEME BAR ──
538
  with gr.Row():
539
  theme_selector = gr.HTML("""
 
704
  ],
705
  outputs=[result, seed, meta_panel, history_html, history_state],
706
  )
707
+ # Note: oauth_token injected automatically by Gradio from LoginButton
708
 
709
  custom_lora_input.input(
710
  add_custom_lora,
 
725
  # ── LAUNCH ────────────────────────────────────────────────────────────────────
726
 
727
  app.queue()
728
+ app.launch()