SpyC0der77 commited on
Commit
feab1f5
·
verified ·
1 Parent(s): c6bfd08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -21
app.py CHANGED
@@ -3,6 +3,13 @@ import numpy as np
3
  import random
4
  import torch
5
  from diffusers import DiffusionPipeline
 
 
 
 
 
 
 
6
 
7
  MAX_SEED = np.iinfo(np.int32).max
8
  MAX_IMAGE_SIZE = 1024
@@ -16,14 +23,12 @@ def infer(
16
  height,
17
  guidance_scale,
18
  num_inference_steps,
19
- user_info,
20
  ):
21
- if not user_info or "username" not in user_info:
22
- return "Please log in to generate images.", None
23
-
24
  # Load the pipeline only when this function is called
25
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
26
- pipe.load_lora_weights("EvanZhouDev/open-genmoji")
 
 
27
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
28
  pipe = pipe.to(device)
29
 
@@ -62,20 +67,6 @@ with gr.Blocks(css=css) as demo:
62
  with gr.Column(elem_id="col-container"):
63
  gr.Markdown(" # Text-to-Image Gradio Template")
64
 
65
- # Login Button inside the Blocks context
66
- login_button = gr.LoginButton()
67
- login_button.activate()
68
- user_info = gr.State()
69
-
70
- def update_user_info(profile):
71
- if profile is None:
72
- return "No user information available"
73
- return profile
74
-
75
- login_button.click(
76
- update_user_info, inputs=None, outputs=user_info
77
- )
78
-
79
  with gr.Row():
80
  prompt = gr.Text(
81
  label="Prompt",
@@ -147,7 +138,6 @@ with gr.Blocks(css=css) as demo:
147
  height,
148
  guidance_scale,
149
  num_inference_steps,
150
- user_info,
151
  ],
152
  outputs=[result, seed],
153
  )
 
3
  import random
4
  import torch
5
  from diffusers import DiffusionPipeline
6
+ from huggingface_hub import login
7
+
8
+ # Replace 'YOUR_HUGGINGFACE_API_TOKEN' with your actual token
9
+ api_token = 'YOUR_HUGGINGFACE_API_TOKEN'
10
+
11
+ # Log in to Hugging Face Hub
12
+ login(token=api_token)
13
 
14
  MAX_SEED = np.iinfo(np.int32).max
15
  MAX_IMAGE_SIZE = 1024
 
23
  height,
24
  guidance_scale,
25
  num_inference_steps,
 
26
  ):
 
 
 
27
  # Load the pipeline only when this function is called
28
+ pipe = DiffusionPipeline.from_pretrained(
29
+ "black-forest-labs/FLUX.1-dev", use_auth_token=api_token
30
+ )
31
+ pipe.load_lora_weights("EvanZhouDev/open-genmoji", use_auth_token=api_token)
32
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
33
  pipe = pipe.to(device)
34
 
 
67
  with gr.Column(elem_id="col-container"):
68
  gr.Markdown(" # Text-to-Image Gradio Template")
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  with gr.Row():
71
  prompt = gr.Text(
72
  label="Prompt",
 
138
  height,
139
  guidance_scale,
140
  num_inference_steps,
 
141
  ],
142
  outputs=[result, seed],
143
  )