fffiloni commited on
Commit
a9a06bb
·
1 Parent(s): 8fa68e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- from huggingface_hub import login, HfFileSystem
3
 
4
  from diffusers import DiffusionPipeline, StableDiffusionXLPipeline
5
  import torch
@@ -13,6 +13,7 @@ hf_token = os.environ.get("HF_TOKEN")
13
  login(token = hf_token)
14
 
15
  fs = HfFileSystem(token=hf_token)
 
16
 
17
  original_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
18
 
@@ -160,11 +161,25 @@ with gr.Blocks(css=css) as demo:
160
  with gr.Row():
161
 
162
  with gr.Column():
 
 
 
 
 
 
163
 
164
- lora_1_id = gr.Textbox(
165
- label = "LoRa 1 ID",
166
- placeholder = "username/model_id"
167
- )
 
 
 
 
 
 
 
 
168
 
169
  lora_1_sfts = gr.Dropdown(
170
  label = "Safetensors file",
 
1
  import gradio as gr
2
+ from huggingface_hub import login, HfFileSystem, HfApi
3
 
4
  from diffusers import DiffusionPipeline, StableDiffusionXLPipeline
5
  import torch
 
13
  login(token = hf_token)
14
 
15
  fs = HfFileSystem(token=hf_token)
16
+ api = HfApi()
17
 
18
  original_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
19
 
 
161
  with gr.Row():
162
 
163
  with gr.Column():
164
+
165
+ if is_shared_ui:
166
+
167
+ your_username = api.whoami()["name"]
168
+ my_models = api.list_models(author=your_username, filter="diffusers")
169
+ print(my_models)
170
 
171
+ lora_1_id = gr.Dropdown()(
172
+ label = "LoRa 1 ID",
173
+ choices = my_models,
174
+ allow_custom_value = True
175
+ #placeholder = "username/model_id"
176
+ )
177
+
178
+ else:
179
+ lora_1_id = gr.Textbox(
180
+ label = "LoRa 1 ID",
181
+ placeholder = "username/model_id"
182
+ )
183
 
184
  lora_1_sfts = gr.Dropdown(
185
  label = "Safetensors file",