amazonaws-la commited on
Commit
1ea0405
1 Parent(s): 446de7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -21
app.py CHANGED
@@ -26,21 +26,6 @@ ENABLE_USE_LORA = os.getenv("ENABLE_USE_LORA", "1") == "1"
26
  ENABLE_USE_VAE = os.getenv("ENABLE_USE_VAE", "1") == "1"
27
 
28
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
29
- models = ["runwayml/stable-diffusion-v1-5",
30
- "stabilityai/stable-diffusion-xl-base-1.0",
31
- "stablediffusionapi/juggernaut-xl-v8",
32
- "emilianJR/epiCRealism",
33
- "SG161222/Realistic_Vision_V5.1_noVAE",
34
- "cagliostrolab/animagine-xl-3.0",
35
- "misri/cyberrealistic_v41BackToBasics",
36
- "malcolmrey/serenity",
37
- "SG161222/RealVisXL_V3.0",
38
- "stablediffusionapi/realistic-stock-photo-v2",
39
- "stablediffusionapi/pixel-art-diffusion-xl",
40
- "playgroundai/playground-v2-1024px-aesthetic",
41
- "dataautogpt3/ProteusV0.3",
42
- "stablediffusionapi/disney-pixar-cartoon",
43
- "RunDiffusion/Juggernaut-XL-Lightning"]
44
 
45
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
46
  if randomize_seed:
@@ -67,7 +52,7 @@ def generate(
67
  use_vae: bool = False,
68
  use_lora: bool = False,
69
  apply_refiner: bool = False,
70
- dropdown_model = 'cagliostrolab/animagine-xl-3.0',
71
  vaecall = 'stabilityai/sd-vae-ft-mse',
72
  lora = 'amazonaws-la/juliette',
73
  lora_scale: float = 0.7,
@@ -75,15 +60,15 @@ def generate(
75
  if torch.cuda.is_available():
76
 
77
  if not use_vae:
78
- pipe = DiffusionPipeline.from_pretrained(dropdown_model, torch_dtype=torch.float16)
79
 
80
  if use_vae:
81
  vae = AutoencoderKL.from_pretrained(vaecall, torch_dtype=torch.float16)
82
- pipe = DiffusionPipeline.from_pretrained(dropdown_model, vae=vae, torch_dtype=torch.float16)
83
 
84
  if use_lora:
85
  pipe.load_lora_weights(lora)
86
- pipe.fuse_lora(lora_scale=0.7)
87
 
88
  if ENABLE_CPU_OFFLOAD:
89
  pipe.enable_model_cpu_offload()
@@ -155,7 +140,7 @@ with gr.Blocks(css="style.css") as demo:
155
  visible=os.getenv("SHOW_DUPLICATE_BUTTON") == "1",
156
  )
157
  with gr.Group():
158
- dropdown_model = gr.Dropdown(label='Model', value='cagliostrolab/animagine-xl-3.0', choices=models)
159
  vaecall = gr.Text(label='VAE')
160
  lora = gr.Text(label='LoRA')
161
  lora_scale = gr.Slider(
@@ -340,7 +325,7 @@ with gr.Blocks(css="style.css") as demo:
340
  use_vae,
341
  use_lora,
342
  apply_refiner,
343
- dropdown_model,
344
  vaecall,
345
  lora,
346
  lora_scale,
 
26
  ENABLE_USE_VAE = os.getenv("ENABLE_USE_VAE", "1") == "1"
27
 
28
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
31
  if randomize_seed:
 
52
  use_vae: bool = False,
53
  use_lora: bool = False,
54
  apply_refiner: bool = False,
55
+ model = 'cagliostrolab/animagine-xl-3.0',
56
  vaecall = 'stabilityai/sd-vae-ft-mse',
57
  lora = 'amazonaws-la/juliette',
58
  lora_scale: float = 0.7,
 
60
  if torch.cuda.is_available():
61
 
62
  if not use_vae:
63
+ pipe = DiffusionPipeline.from_pretrained(model, torch_dtype=torch.float16)
64
 
65
  if use_vae:
66
  vae = AutoencoderKL.from_pretrained(vaecall, torch_dtype=torch.float16)
67
+ pipe = DiffusionPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16)
68
 
69
  if use_lora:
70
  pipe.load_lora_weights(lora)
71
+ pipe.fuse_lora(lora_scale)
72
 
73
  if ENABLE_CPU_OFFLOAD:
74
  pipe.enable_model_cpu_offload()
 
140
  visible=os.getenv("SHOW_DUPLICATE_BUTTON") == "1",
141
  )
142
  with gr.Group():
143
+ model = gr.Text(label='Model')
144
  vaecall = gr.Text(label='VAE')
145
  lora = gr.Text(label='LoRA')
146
  lora_scale = gr.Slider(
 
325
  use_vae,
326
  use_lora,
327
  apply_refiner,
328
+ model,
329
  vaecall,
330
  lora,
331
  lora_scale,