Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -22,13 +22,14 @@ pipe = pipe.to(device)
|
|
22 |
MAX_SEED = np.iinfo(np.int32).max
|
23 |
MAX_IMAGE_SIZE = 1024
|
24 |
|
25 |
-
def update_model_version(version):
|
26 |
"""Update the model version dynamically based on the selected version."""
|
27 |
global model_repo_id, pipe
|
28 |
model_repo_id = f"John6666/wai-ani-nsfw-ponyxl-{version}-sdxl"
|
29 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
30 |
pipe = pipe.to(device)
|
31 |
print(f"Model switched to {model_repo_id}")
|
|
|
32 |
|
33 |
@spaces.GPU # [uncomment to use ZeroGPU]
|
34 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
@@ -236,15 +237,16 @@ with gr.Blocks(css=css) as demo:
|
|
236 |
selected_atmosphere_tags = gr.CheckboxGroup(choices=list(atmosphere_tags.keys()), label="Atmosphere Tags")
|
237 |
tag_tab.select(lambda: "Tag Selection", inputs=None, outputs=active_tab)
|
238 |
|
239 |
-
#
|
240 |
with gr.Row(elem_id="button-group"):
|
241 |
-
link_button_v7 = gr.Button("V7 Model",
|
242 |
-
link_button_v8 = gr.Button("V8 Model",
|
243 |
-
link_button_v11 = gr.Button("V11 Model",
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
248 |
|
249 |
run_button.click(
|
250 |
infer,
|
|
|
22 |
MAX_SEED = np.iinfo(np.int32).max
|
23 |
MAX_IMAGE_SIZE = 1024
|
24 |
|
25 |
+
def update_model_version(version, state_model_repo_id):
|
26 |
"""Update the model version dynamically based on the selected version."""
|
27 |
global model_repo_id, pipe
|
28 |
model_repo_id = f"John6666/wai-ani-nsfw-ponyxl-{version}-sdxl"
|
29 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
30 |
pipe = pipe.to(device)
|
31 |
print(f"Model switched to {model_repo_id}")
|
32 |
+
state_model_repo_id.set(model_repo_id) # Update the state with the new model version
|
33 |
|
34 |
@spaces.GPU # [uncomment to use ZeroGPU]
|
35 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
|
|
237 |
selected_atmosphere_tags = gr.CheckboxGroup(choices=list(atmosphere_tags.keys()), label="Atmosphere Tags")
|
238 |
tag_tab.select(lambda: "Tag Selection", inputs=None, outputs=active_tab)
|
239 |
|
240 |
+
# Horizontal buttons to switch models
|
241 |
with gr.Row(elem_id="button-group"):
|
242 |
+
link_button_v7 = gr.Button("V7 Model", variant="primary")
|
243 |
+
link_button_v8 = gr.Button("V8 Model", variant="primary")
|
244 |
+
link_button_v11 = gr.Button("V11 Model", variant="primary")
|
245 |
+
|
246 |
+
# Set the model version based on the button clicked
|
247 |
+
link_button_v7.click(update_model_version, inputs=["v7"], outputs=[])
|
248 |
+
link_button_v8.click(update_model_version, inputs=["v8"], outputs=[])
|
249 |
+
link_button_v11.click(update_model_version, inputs=["v11"], outputs=[])
|
250 |
|
251 |
run_button.click(
|
252 |
infer,
|