Spaces:
Sleeping
Sleeping
Avijit Ghosh
commited on
Commit
•
fadf2e1
1
Parent(s):
e7204ee
add login
Browse files
app.py
CHANGED
@@ -122,9 +122,9 @@ def skintoneplot(hex_codes):
|
|
122 |
return fig
|
123 |
|
124 |
@spaces.GPU
|
125 |
-
def generate_images_plots(prompt, model_name):
|
126 |
global pipeline_text2image
|
127 |
-
pipeline_text2image = load_model(model_name)
|
128 |
foldername = "temp"
|
129 |
Path(foldername).mkdir(parents=True, exist_ok=True)
|
130 |
images = [getimgen(prompt, model_name) for _ in range(10)]
|
@@ -167,11 +167,12 @@ with gr.Blocks(title="Skin Tone and Gender bias in Text to Image Models") as dem
|
|
167 |
height="auto"
|
168 |
)
|
169 |
gr.LoginButton()
|
|
|
170 |
gr.Markdown('### You need to log in to your Hugging Face account to run Stable Diffusion 3')
|
171 |
btn = gr.Button("Generate images", scale=0)
|
172 |
with gr.Row(equal_height=True):
|
173 |
skinplot = gr.Plot(label="Skin Tone")
|
174 |
genplot = gr.Plot(label="Gender")
|
175 |
-
btn.click(generate_images_plots, inputs=[prompt, model_dropdown], outputs=[gallery, skinplot, genplot])
|
176 |
|
177 |
demo.launch(debug=True)
|
|
|
122 |
return fig
|
123 |
|
124 |
@spaces.GPU
|
125 |
+
def generate_images_plots(prompt, model_name, token=None):
|
126 |
global pipeline_text2image
|
127 |
+
pipeline_text2image = load_model(model_name, token)
|
128 |
foldername = "temp"
|
129 |
Path(foldername).mkdir(parents=True, exist_ok=True)
|
130 |
images = [getimgen(prompt, model_name) for _ in range(10)]
|
|
|
167 |
height="auto"
|
168 |
)
|
169 |
gr.LoginButton()
|
170 |
+
token = gr.OAuthToken()
|
171 |
gr.Markdown('### You need to log in to your Hugging Face account to run Stable Diffusion 3')
|
172 |
btn = gr.Button("Generate images", scale=0)
|
173 |
with gr.Row(equal_height=True):
|
174 |
skinplot = gr.Plot(label="Skin Tone")
|
175 |
genplot = gr.Plot(label="Gender")
|
176 |
+
btn.click(generate_images_plots, inputs=[prompt, model_dropdown, token], outputs=[gallery, skinplot, genplot])
|
177 |
|
178 |
demo.launch(debug=True)
|