Spaces:
Sleeping
Sleeping
Added possibility to specify safetensors
Browse files
app.py
CHANGED
@@ -60,7 +60,7 @@ def resize_image(input_path, output_path, target_height):
|
|
60 |
|
61 |
return output_path
|
62 |
|
63 |
-
def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
|
64 |
prompt = prompt
|
65 |
negative_prompt = negative_prompt
|
66 |
generator = torch.Generator(device=device).manual_seed(seed)
|
@@ -88,7 +88,7 @@ def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, ne
|
|
88 |
custom_model = model_name
|
89 |
|
90 |
# This is where you load your trained weights
|
91 |
-
pipe.load_lora_weights(custom_model, use_auth_token=True)
|
92 |
|
93 |
lora_scale=custom_lora_weight
|
94 |
|
@@ -183,13 +183,14 @@ with gr.Blocks(css=css) as demo:
|
|
183 |
use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
|
184 |
with gr.Row():
|
185 |
model_name = gr.Textbox(label="Custom Model to use", placeholder="username/my_custom_public_model")
|
|
|
186 |
custom_lora_weight = gr.Slider(label="Custom model weights", minimum=0.1, maximum=0.9, step=0.1, value=0.9)
|
187 |
submit_btn = gr.Button("Submit")
|
188 |
result = gr.Image(label="Result")
|
189 |
|
190 |
submit_btn.click(
|
191 |
fn = infer,
|
192 |
-
inputs = [use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed],
|
193 |
outputs = [result]
|
194 |
)
|
195 |
|
|
|
60 |
|
61 |
return output_path
|
62 |
|
63 |
+
def infer(use_custom_model, model_name, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
|
64 |
prompt = prompt
|
65 |
negative_prompt = negative_prompt
|
66 |
generator = torch.Generator(device=device).manual_seed(seed)
|
|
|
88 |
custom_model = model_name
|
89 |
|
90 |
# This is where you load your trained weights
|
91 |
+
pipe.load_lora_weights(custom_model, weight_name=weight_name, use_auth_token=True)
|
92 |
|
93 |
lora_scale=custom_lora_weight
|
94 |
|
|
|
183 |
use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
|
184 |
with gr.Row():
|
185 |
model_name = gr.Textbox(label="Custom Model to use", placeholder="username/my_custom_public_model")
|
186 |
+
weight_name = gr.Textbox(label="Specific safetensor", placeholder="specific_weight.safetensors")
|
187 |
custom_lora_weight = gr.Slider(label="Custom model weights", minimum=0.1, maximum=0.9, step=0.1, value=0.9)
|
188 |
submit_btn = gr.Button("Submit")
|
189 |
result = gr.Image(label="Result")
|
190 |
|
191 |
submit_btn.click(
|
192 |
fn = infer,
|
193 |
+
inputs = [use_custom_model, model_name, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed],
|
194 |
outputs = [result]
|
195 |
)
|
196 |
|