Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -56,11 +56,12 @@ def scrape_lora_link(url):
|
|
56 |
except requests.RequestException as e:
|
57 |
raise gr.Error(f"An error occurred while fetching the URL: {e}")
|
58 |
|
59 |
-
def enable_lora(lora_scale,lora_add):
|
|
|
60 |
if not lora_add:
|
61 |
gr.Info("No Lora Loaded, Use basemodel")
|
|
|
62 |
else:
|
63 |
-
pipe.unload_lora_weights()
|
64 |
url = f'https://huggingface.co/{lora_add}/tree/main'
|
65 |
lora_name = scrape_lora_link(url)
|
66 |
if lora_name:
|
@@ -68,11 +69,13 @@ def enable_lora(lora_scale,lora_add):
|
|
68 |
pipe.load_lora_weights(lora_add, weight_name=lora_name)
|
69 |
pipe.fuse_lora(lora_scale=lora_scale)
|
70 |
gr.Info(f"{lora_add} Loaded")
|
|
|
71 |
else:
|
72 |
try:
|
73 |
pipe.load_lora_weights(lora_add)
|
74 |
pipe.fuse_lora(lora_scale=lora_scale)
|
75 |
gr.Info(f"{lora_add} Loaded")
|
|
|
76 |
except:
|
77 |
raise gr.Error(f"{lora_add} Load fail, check again.")
|
78 |
|
@@ -186,10 +189,9 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
186 |
value=1.0,
|
187 |
)
|
188 |
lora_add = gr.Textbox(
|
189 |
-
label="
|
190 |
info="Copy the HF LoRA model name here",
|
191 |
lines=1,
|
192 |
-
value="Shakker-Labs/AWPortrait-FL",
|
193 |
)
|
194 |
lora_word = gr.Textbox(
|
195 |
label="Add Flux LoRA Trigger Word",
|
@@ -206,7 +208,7 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
206 |
examples_per_page=4,
|
207 |
)
|
208 |
|
209 |
-
load_lora.click(fn=enable_lora, inputs=[lora_scale,lora_add])
|
210 |
|
211 |
gr.on(
|
212 |
triggers=[
|
|
|
56 |
except requests.RequestException as e:
|
57 |
raise gr.Error(f"An error occurred while fetching the URL: {e}")
|
58 |
|
59 |
+
def enable_lora(lora_scale,lora_add,progress=gr.Progress(track_tqdm=True)):
|
60 |
+
pipe.unload_lora_weights()
|
61 |
if not lora_add:
|
62 |
gr.Info("No Lora Loaded, Use basemodel")
|
63 |
+
return gr.update(value="")
|
64 |
else:
|
|
|
65 |
url = f'https://huggingface.co/{lora_add}/tree/main'
|
66 |
lora_name = scrape_lora_link(url)
|
67 |
if lora_name:
|
|
|
69 |
pipe.load_lora_weights(lora_add, weight_name=lora_name)
|
70 |
pipe.fuse_lora(lora_scale=lora_scale)
|
71 |
gr.Info(f"{lora_add} Loaded")
|
72 |
+
return gr.update(label="LoRA Loaded Now")
|
73 |
else:
|
74 |
try:
|
75 |
pipe.load_lora_weights(lora_add)
|
76 |
pipe.fuse_lora(lora_scale=lora_scale)
|
77 |
gr.Info(f"{lora_add} Loaded")
|
78 |
+
return gr.update(label="LoRA Loaded Now")
|
79 |
except:
|
80 |
raise gr.Error(f"{lora_add} Load fail, check again.")
|
81 |
|
|
|
189 |
value=1.0,
|
190 |
)
|
191 |
lora_add = gr.Textbox(
|
192 |
+
label="Flux LoRA",
|
193 |
info="Copy the HF LoRA model name here",
|
194 |
lines=1,
|
|
|
195 |
)
|
196 |
lora_word = gr.Textbox(
|
197 |
label="Add Flux LoRA Trigger Word",
|
|
|
208 |
examples_per_page=4,
|
209 |
)
|
210 |
|
211 |
+
load_lora.click(fn=enable_lora, inputs=[lora_scale,lora_add], outputs=lora_add)
|
212 |
|
213 |
gr.on(
|
214 |
triggers=[
|