anzorq commited on
Commit
f5d967f
1 Parent(s): cf3bb2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  from huggingface_hub import HfApi, upload_folder
3
  import gradio as gr
4
 
@@ -29,8 +30,8 @@ def get_my_model_names(token):
29
  if has_diffusion_model(model_id, token):
30
  model_names.append(model_id)
31
 
32
- # if not model_names:
33
- # return [], Exception("No diffusion models found in your account.")
34
 
35
  return model_names, None
36
 
@@ -38,9 +39,10 @@ def get_my_model_names(token):
38
  return [], e
39
 
40
  def on_token_change(token):
41
- model_names, error = get_my_model_names(token)
 
42
 
43
- return gr.update(visible=not error), gr.update(choices=model_names), gr.update(value=error_str(error))
44
 
45
  def on_load_model(user_model_id, other_model_id, token):
46
 
@@ -192,5 +194,8 @@ with gr.Blocks() as demo:
192
  </div>
193
  """)
194
 
195
- demo.queue()
196
  demo.launch(debug=True)
 
 
 
 
1
  import os
2
+ import subprocess
3
  from huggingface_hub import HfApi, upload_folder
4
  import gradio as gr
5
 
 
30
  if has_diffusion_model(model_id, token):
31
  model_names.append(model_id)
32
 
33
+ if not model_names:
34
+ return [], Exception("No diffusion models found in your account.")
35
 
36
  return model_names, None
37
 
 
39
  return [], e
40
 
41
  def on_token_change(token):
42
+ if token:
43
+ model_names, error = get_my_model_names(token)
44
 
45
+ return gr.update(visible=not error, choices=model_names, label="Select a model:"), error_str(error)
46
 
47
  def on_load_model(user_model_id, other_model_id, token):
48
 
 
194
  </div>
195
  """)
196
 
197
+ # demo.queue()
198
  demo.launch(debug=True)
199
+
200
+ # Tweet presenting this space:
201
+ # Made a space which lets you easily create a gradio demo for your Diffusers🧨 model and share it with the community in just a few clicks! 🚀