multimodalart HF staff commited on
Commit
dddd981
·
verified ·
1 Parent(s): f1c7db2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -20,13 +20,17 @@ MAX_SEED = np.iinfo(np.int32).max
20
  MAX_IMAGE_SIZE = 1024
21
 
22
  @spaces.GPU(duration=75) #[uncomment to use ZeroGPU]
23
- def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, true_guidance, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
24
 
25
  if randomize_seed:
26
  seed = random.randint(0, MAX_SEED)
27
 
28
  generator = torch.Generator().manual_seed(seed)
 
29
 
 
 
 
30
  image = pipe(
31
  prompt = prompt,
32
  negative_prompt = negative_prompt,
@@ -96,7 +100,7 @@ with gr.Blocks(css=css) as demo:
96
 
97
  with gr.Accordion("Advanced Settings", open=False):
98
 
99
-
100
 
101
  seed = gr.Slider(
102
  label="Seed",
@@ -145,7 +149,7 @@ with gr.Blocks(css=css) as demo:
145
  gr.on(
146
  triggers=[run_button.click, prompt.submit, negative_prompt.submit],
147
  fn = infer,
148
- inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, true_guidance, num_inference_steps],
149
  outputs = [result, seed]
150
  )
151
 
 
20
  MAX_IMAGE_SIZE = 1024
21
 
22
  @spaces.GPU(duration=75) #[uncomment to use ZeroGPU]
23
+ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, true_guidance, num_inference_steps, lora_model, progress=gr.Progress(track_tqdm=True)):
24
 
25
  if randomize_seed:
26
  seed = random.randint(0, MAX_SEED)
27
 
28
  generator = torch.Generator().manual_seed(seed)
29
+ pipe.unload_lora_weights()
30
 
31
+ if lora_model is not None:
32
+ pipe.load_lora_weights(lora_model)
33
+
34
  image = pipe(
35
  prompt = prompt,
36
  negative_prompt = negative_prompt,
 
100
 
101
  with gr.Accordion("Advanced Settings", open=False):
102
 
103
+ lora_model = gr.Textbox(label="LoRA model id", placeholder="multimodalart/flux-tarot-v1 ")
104
 
105
  seed = gr.Slider(
106
  label="Seed",
 
149
  gr.on(
150
  triggers=[run_button.click, prompt.submit, negative_prompt.submit],
151
  fn = infer,
152
+ inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, true_guidance, num_inference_steps, lora_model],
153
  outputs = [result, seed]
154
  )
155