silveroxides commited on
Commit
c303ab0
1 Parent(s): 3f71c95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -61,7 +61,7 @@ def download_file(url, folder_path, filename):
61
  # Download ESRGAN models
62
  download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth?download=true", "models/upscalers/", "RealESRGAN_x2.pth")
63
  download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth?download=true", "models/upscalers/", "RealESRGAN_x4.pth")
64
-
65
  # Download the model files
66
  ckpt_dir_realpony = snapshot_download(repo_id="silveroxides/RNS_RealPonyV20")
67
  ckpt_dir_noobai = snapshot_download(repo_id="silveroxides/NoobAI-XL-EPS-1.0-Vwe")
@@ -207,12 +207,12 @@ def upscale_image(image, scale):
207
 
208
  @spaces.GPU(duration=120)
209
  def generate_image(model_choice, additional_positive_prompt, additional_negative_prompt, height, width, num_inference_steps,
210
- guidance_scale, pag_scale, pag_layers, num_images_per_prompt, use_random_seed, seed, sampler, clip_skip,
211
  use_florence2, use_medium_enhancer, use_long_enhancer,
212
  use_positive_prefix, use_positive_suffix, use_negative_prefix, use_negative_suffix,
213
  use_upscaler, upscale_factor,
214
  input_image=None, progress=gr.Progress(track_tqdm=True)):
215
-
216
  # Select the appropriate pipe based on the model choice
217
  if model_choice == "Real Pony RNS":
218
  pipe = pipe_realpony
@@ -220,12 +220,15 @@ def generate_image(model_choice, additional_positive_prompt, additional_negative
220
  pipe = pipe_noobai
221
  else: # "Hybrid Pony SDXL"
222
  pipe = pipe_hybridpony
223
-
 
 
 
224
  if use_random_seed:
225
  seed = random.randint(0, 2**32 - 1)
226
  else:
227
  seed = int(seed) # Ensure seed is an integer
228
-
229
  # Set the scheduler based on the selected sampler
230
  pipe.scheduler = samplers[sampler]
231
 
@@ -331,6 +334,7 @@ with gr.Blocks(theme='bethecloud/storj_theme') as demo:
331
  pag_scale = gr.Number(label="Pag Scale", value=3.0)
332
  pag_layers = gr.Dropdown(label="Model layers to apply Pag to", info="mid is the one used on the paper, up and down blocks seem unstable", choices=["up", "mid", "down"], multiselect=True, value="mid")
333
  num_images_per_prompt = gr.Slider(1, 4, 1, step=1, label="Number of images per prompt")
 
334
  use_random_seed = gr.Checkbox(label="Use Random Seed", value=True)
335
  seed = gr.Number(label="Seed", value=0, precision=0)
336
  sampler = gr.Dropdown(label="Sampler", choices=list(samplers.keys()), value="Euler a")
@@ -381,7 +385,7 @@ with gr.Blocks(theme='bethecloud/storj_theme') as demo:
381
  inputs=[
382
  model_choice, # Add this new input
383
  positive_prompt, negative_prompt, height, width, num_inference_steps,
384
- guidance_scale, pag_scale, pag_layers, num_images_per_prompt, use_random_seed, seed, sampler,
385
  clip_skip, use_florence2, use_medium_enhancer, use_long_enhancer,
386
  use_positive_prefix, use_positive_suffix, use_negative_prefix, use_negative_suffix,
387
  use_upscaler, upscale_factor,
 
61
  # Download ESRGAN models
62
  download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth?download=true", "models/upscalers/", "RealESRGAN_x2.pth")
63
  download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth?download=true", "models/upscalers/", "RealESRGAN_x4.pth")
64
+ lowstep_lora_repo = 'silveroxides/sdxl_lowstep_beta_v1'
65
  # Download the model files
66
  ckpt_dir_realpony = snapshot_download(repo_id="silveroxides/RNS_RealPonyV20")
67
  ckpt_dir_noobai = snapshot_download(repo_id="silveroxides/NoobAI-XL-EPS-1.0-Vwe")
 
207
 
208
  @spaces.GPU(duration=120)
209
  def generate_image(model_choice, additional_positive_prompt, additional_negative_prompt, height, width, num_inference_steps,
210
+ guidance_scale, pag_scale, pag_layers, num_images_per_prompt, use_lowstep_lora, use_random_seed, seed, sampler, clip_skip,
211
  use_florence2, use_medium_enhancer, use_long_enhancer,
212
  use_positive_prefix, use_positive_suffix, use_negative_prefix, use_negative_suffix,
213
  use_upscaler, upscale_factor,
214
  input_image=None, progress=gr.Progress(track_tqdm=True)):
215
+
216
  # Select the appropriate pipe based on the model choice
217
  if model_choice == "Real Pony RNS":
218
  pipe = pipe_realpony
 
220
  pipe = pipe_noobai
221
  else: # "Hybrid Pony SDXL"
222
  pipe = pipe_hybridpony
223
+
224
+ if use_lowstep_lora:
225
+ pipe.load_lora_weights(lowstep_lora_repo, weight_name='pytorch_lora_weights.safetensors')
226
+
227
  if use_random_seed:
228
  seed = random.randint(0, 2**32 - 1)
229
  else:
230
  seed = int(seed) # Ensure seed is an integer
231
+
232
  # Set the scheduler based on the selected sampler
233
  pipe.scheduler = samplers[sampler]
234
 
 
334
  pag_scale = gr.Number(label="Pag Scale", value=3.0)
335
  pag_layers = gr.Dropdown(label="Model layers to apply Pag to", info="mid is the one used on the paper, up and down blocks seem unstable", choices=["up", "mid", "down"], multiselect=True, value="mid")
336
  num_images_per_prompt = gr.Slider(1, 4, 1, step=1, label="Number of images per prompt")
337
+ use_lowstep_lora = gr.Checkbox(label="Use Lowstep LoRA", value=False)
338
  use_random_seed = gr.Checkbox(label="Use Random Seed", value=True)
339
  seed = gr.Number(label="Seed", value=0, precision=0)
340
  sampler = gr.Dropdown(label="Sampler", choices=list(samplers.keys()), value="Euler a")
 
385
  inputs=[
386
  model_choice, # Add this new input
387
  positive_prompt, negative_prompt, height, width, num_inference_steps,
388
+ guidance_scale, pag_scale, pag_layers, num_images_per_prompt, use_lowstep_lora, use_random_seed, seed, sampler,
389
  clip_skip, use_florence2, use_medium_enhancer, use_long_enhancer,
390
  use_positive_prefix, use_positive_suffix, use_negative_prefix, use_negative_suffix,
391
  use_upscaler, upscale_factor,