Spaces:
Sleeping
Sleeping
se usa el lora de la galería
Browse files- app.py +28 -5
- loras.json +6 -0
app.py
CHANGED
@@ -5,19 +5,27 @@ from gradio_client import Client
|
|
5 |
|
6 |
with open('loras.json', 'r') as f:
|
7 |
loras = json.load(f)
|
|
|
8 |
|
9 |
-
def infer (prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
client = Client("fffiloni/sd-xl-custom-model")
|
14 |
result = client.predict(
|
15 |
custom_model=custom_model,
|
16 |
api_name="/load_model"
|
17 |
)
|
|
|
18 |
|
19 |
client = Client("fffiloni/sd-xl-custom-model")
|
20 |
-
prompt = "
|
21 |
result = client.predict(
|
22 |
custom_model=custom_model,
|
23 |
weight_name=weight_name,
|
@@ -92,6 +100,7 @@ with gr.Blocks(css=css) as demo:
|
|
92 |
style_prompt_in = gr.Textbox(
|
93 |
label="Your Style Prompt"
|
94 |
)
|
|
|
95 |
used_prompt = gr.Textbox(
|
96 |
label="Used prompt"
|
97 |
)
|
@@ -159,11 +168,25 @@ with gr.Blocks(css=css) as demo:
|
|
159 |
)
|
160 |
submit_btn = gr.Button("Submit")
|
161 |
image_out = gr.Image(label="Image output")
|
|
|
162 |
|
163 |
submit_btn.click(
|
164 |
fn = infer,
|
165 |
-
inputs = [prompt_in, style_prompt_in, inf_steps, guidance_scale, width, height, seed, lora_weight],
|
166 |
outputs = [image_out, last_used_seed, used_prompt]
|
167 |
)
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
demo.launch()
|
|
|
5 |
|
6 |
with open('loras.json', 'r') as f:
|
7 |
loras = json.load(f)
|
8 |
+
|
9 |
|
10 |
+
def infer (selected_index, prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
|
11 |
+
if selected_index is None:
|
12 |
+
raise gr.Error("You must select a LoRA before proceeding.")
|
13 |
+
|
14 |
+
# custom_model="lichorosario/dott_remastered_style_lora_sdxl"
|
15 |
+
# weight_name="dott_style.safetensors"
|
16 |
+
selected_lora = loras[selected_index]
|
17 |
+
custom_model = selected_lora["repo"]
|
18 |
+
trigger_word = selected_lora["trigger_word"]
|
19 |
|
20 |
client = Client("fffiloni/sd-xl-custom-model")
|
21 |
result = client.predict(
|
22 |
custom_model=custom_model,
|
23 |
api_name="/load_model"
|
24 |
)
|
25 |
+
weight_name = result[2]['value']
|
26 |
|
27 |
client = Client("fffiloni/sd-xl-custom-model")
|
28 |
+
prompt = trigger_word+". "+prompt+". "+style_prompt
|
29 |
result = client.predict(
|
30 |
custom_model=custom_model,
|
31 |
weight_name=weight_name,
|
|
|
100 |
style_prompt_in = gr.Textbox(
|
101 |
label="Your Style Prompt"
|
102 |
)
|
103 |
+
selected_info = gr.Markdown("")
|
104 |
used_prompt = gr.Textbox(
|
105 |
label="Used prompt"
|
106 |
)
|
|
|
168 |
)
|
169 |
submit_btn = gr.Button("Submit")
|
170 |
image_out = gr.Image(label="Image output")
|
171 |
+
selected_index = gr.State(None)
|
172 |
|
173 |
submit_btn.click(
|
174 |
fn = infer,
|
175 |
+
inputs = [selected_index, prompt_in, style_prompt_in, inf_steps, guidance_scale, width, height, seed, lora_weight],
|
176 |
outputs = [image_out, last_used_seed, used_prompt]
|
177 |
)
|
178 |
|
179 |
+
def update_selection(evt: gr.SelectData):
|
180 |
+
selected_lora = loras[evt.index]
|
181 |
+
new_placeholder = f"Type a prompt for {selected_lora['title']}"
|
182 |
+
lora_repo = selected_lora["repo"]
|
183 |
+
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
184 |
+
return (
|
185 |
+
gr.update(placeholder=new_placeholder),
|
186 |
+
updated_text,
|
187 |
+
evt.index
|
188 |
+
)
|
189 |
+
|
190 |
+
gallery.select(update_selection, outputs=[prompt_in, selected_info, selected_index])
|
191 |
+
|
192 |
demo.launch()
|
loras.json
CHANGED
@@ -4,5 +4,11 @@
|
|
4 |
"title": "Day of the Tentacle Remastered",
|
5 |
"repo": "lichorosario/dott_remastered_style_lora_sdxl",
|
6 |
"trigger_word": "dott style"
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
]
|
|
|
4 |
"title": "Day of the Tentacle Remastered",
|
5 |
"repo": "lichorosario/dott_remastered_style_lora_sdxl",
|
6 |
"trigger_word": "dott style"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"image": "images/sam_and_max.jpg",
|
10 |
+
"title": "Sam and Max",
|
11 |
+
"repo": "lichorosario/sam-and-max",
|
12 |
+
"trigger_word": ""
|
13 |
}
|
14 |
]
|