Lifeinhockey commited on
Commit
a20297c
·
verified ·
1 Parent(s): bf95b09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
app.py CHANGED
@@ -6,7 +6,6 @@ from peft import PeftModel, LoraConfig
6
  import os
7
 
8
  def get_lora_sd_pipeline(
9
- #ckpt_dir='./lora_logos',
10
  ckpt_dir='./lora_man_animestyle',
11
  base_model_name_or_path=None,
12
  dtype=torch.float16,
@@ -54,11 +53,9 @@ def align_embeddings(prompt_embeds, negative_prompt_embeds):
54
  torch.nn.functional.pad(negative_prompt_embeds, (0, 0, 0, max_length - negative_prompt_embeds.shape[1]))
55
 
56
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
57
- #model_id_default = "CompVis/stable-diffusion-v1-4"
58
  model_id_default = "stable-diffusion-v1-5/stable-diffusion-v1-5"
59
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
60
 
61
- #pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_logos', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
62
  pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_man_animestyle', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
63
 
64
 
@@ -71,7 +68,6 @@ def infer(
71
  width=512,
72
  height=512,
73
  num_inference_steps=20,
74
- #model_id='CompVis/stable-diffusion-v1-4',
75
  model_id='stable-diffusion-v1-5/stable-diffusion-v1-5',
76
  seed=42,
77
  guidance_scale=7.0,
@@ -120,9 +116,8 @@ with gr.Blocks(css=css) as demo:
120
 
121
  with gr.Row():
122
  model_id = gr.Textbox(
123
- label="Model ID",
124
  max_lines=1,
125
- #placeholder="Enter model id like 'CompVis/stable-diffusion-v1-4'",
126
  placeholder="Enter model id like 'stable-diffusion-v1-5/stable-diffusion-v1-5'",
127
  value=model_id_default
128
  )
@@ -140,13 +135,13 @@ with gr.Blocks(css=css) as demo:
140
  )
141
 
142
  with gr.Row():
143
- seed = gr.Number(
144
- label="Seed",
145
- minimum=0,
146
- maximum=MAX_SEED,
147
- step=1,
148
- value=42,
149
- )
150
 
151
  with gr.Row():
152
  guidance_scale = gr.Slider(
@@ -154,16 +149,16 @@ with gr.Blocks(css=css) as demo:
154
  minimum=0.0,
155
  maximum=10.0,
156
  step=0.1,
157
- value=7.0,
158
- )
159
-
160
  with gr.Row():
161
- lora_scale = gr.Slider(
162
- label="LoRA scale",
163
- minimum=0.0,
164
- maximum=1.0,
165
- step=0.1,
166
- value=0.5,
167
  )
168
 
169
  with gr.Row():
 
6
  import os
7
 
8
  def get_lora_sd_pipeline(
 
9
  ckpt_dir='./lora_man_animestyle',
10
  base_model_name_or_path=None,
11
  dtype=torch.float16,
 
53
  torch.nn.functional.pad(negative_prompt_embeds, (0, 0, 0, max_length - negative_prompt_embeds.shape[1]))
54
 
55
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
56
  model_id_default = "stable-diffusion-v1-5/stable-diffusion-v1-5"
57
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
58
 
 
59
  pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_man_animestyle', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
60
 
61
 
 
68
  width=512,
69
  height=512,
70
  num_inference_steps=20,
 
71
  model_id='stable-diffusion-v1-5/stable-diffusion-v1-5',
72
  seed=42,
73
  guidance_scale=7.0,
 
116
 
117
  with gr.Row():
118
  model_id = gr.Textbox(
119
+ label="Model",
120
  max_lines=1,
 
121
  placeholder="Enter model id like 'stable-diffusion-v1-5/stable-diffusion-v1-5'",
122
  value=model_id_default
123
  )
 
135
  )
136
 
137
  with gr.Row():
138
+ lora_scale = gr.Slider(
139
+ label="LoRA scale",
140
+ minimum=0.0,
141
+ maximum=1.0,
142
+ step=0.1,
143
+ value=0.5,
144
+ )
145
 
146
  with gr.Row():
147
  guidance_scale = gr.Slider(
 
149
  minimum=0.0,
150
  maximum=10.0,
151
  step=0.1,
152
+ value=7.5,
153
+ )
154
+
155
  with gr.Row():
156
+ seed = gr.Number(
157
+ label="Seed",
158
+ minimum=0,
159
+ maximum=MAX_SEED,
160
+ step=1,
161
+ value=42,
162
  )
163
 
164
  with gr.Row():