enzokro commited on
Commit
4af4b79
1 Parent(s): ffaff65

support proper types on the cpu

Browse files
Files changed (2) hide show
  1. app.ipynb +7 -3
  2. app.py +12 -8
app.ipynb CHANGED
@@ -35,9 +35,13 @@
35
  "######################################\n",
36
  "######################################\n",
37
  "model_name = 'stabilityai/stable-diffusion-2'\n",
38
- "revision = 'fp16'\n",
39
- "dtype = torch.float16\n",
40
  "device = ('cpu','cuda')[torch.cuda.is_available()]\n",
 
 
 
 
 
 
41
  "\n",
42
  "# model parameters\n",
43
  "better_vae = ''\n",
@@ -217,7 +221,7 @@
217
  " compare_dynamic_guidance,\n",
218
  " inputs=\"text\",\n",
219
  " outputs=gr.Gallery(),\n",
220
- " title=\"Comparison with dynamic Classifier-free Guidance Comparison\",\n",
221
  ")\n",
222
  "iface.launch()\n"
223
  ]
 
35
  "######################################\n",
36
  "######################################\n",
37
  "model_name = 'stabilityai/stable-diffusion-2'\n",
 
 
38
  "device = ('cpu','cuda')[torch.cuda.is_available()]\n",
39
+ "if device == 'cuda':\n",
40
+ " revision = 'fp16'\n",
41
+ " dtype = torch.float16\n",
42
+ "else:\n",
43
+ " revision = 'fp32'\n",
44
+ " dtype = torch.float32\n",
45
  "\n",
46
  "# model parameters\n",
47
  "better_vae = ''\n",
 
221
  " compare_dynamic_guidance,\n",
222
  " inputs=\"text\",\n",
223
  " outputs=gr.Gallery(),\n",
224
+ " title=\"Comparing image generations with dynamic Classifier-free Guidance\",\n",
225
  ")\n",
226
  "iface.launch()\n"
227
  ]
app.py CHANGED
@@ -1,11 +1,11 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['model_name', 'revision', 'dtype', 'device', 'better_vae', 'unet_attn_slice', 'sampler_kls', 'hf_sampler',
5
- 'model_kwargs', 'num_steps', 'height', 'width', 'k_sampler', 'use_karras_sigmas', 'NEG_PROMPT',
6
- 'generation_kwargs', 'baseline_g', 'max_val', 'min_val', 'num_warmup_steps', 'warmup_init_val', 'num_cycles',
7
- 'k_decay', 'DEFAULT_COS_PARAMS', 'static_sched', 'k_sched', 'inv_k_sched', 'scheds', 'iface', 'load_model',
8
- 'cos_harness', 'compare_dynamic_guidance']
9
 
10
  # %% app.ipynb 1
11
  import gradio as gr
@@ -19,9 +19,13 @@ import nbdev
19
  ######################################
20
  ######################################
21
  model_name = 'stabilityai/stable-diffusion-2'
22
- revision = 'fp16'
23
- dtype = torch.float16
24
  device = ('cpu','cuda')[torch.cuda.is_available()]
 
 
 
 
 
 
25
 
26
  # model parameters
27
  better_vae = ''
@@ -168,7 +172,7 @@ iface = gr.Interface(
168
  compare_dynamic_guidance,
169
  inputs="text",
170
  outputs=gr.Gallery(),
171
- title="Comparison with dynamic Classifier-free Guidance Comparison",
172
  )
173
  iface.launch()
174
 
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['model_name', 'device', 'better_vae', 'unet_attn_slice', 'sampler_kls', 'hf_sampler', 'model_kwargs', 'num_steps',
5
+ 'height', 'width', 'k_sampler', 'use_karras_sigmas', 'NEG_PROMPT', 'generation_kwargs', 'baseline_g',
6
+ 'max_val', 'min_val', 'num_warmup_steps', 'warmup_init_val', 'num_cycles', 'k_decay', 'DEFAULT_COS_PARAMS',
7
+ 'static_sched', 'k_sched', 'inv_k_sched', 'scheds', 'iface', 'load_model', 'cos_harness',
8
+ 'compare_dynamic_guidance']
9
 
10
  # %% app.ipynb 1
11
  import gradio as gr
 
19
  ######################################
20
  ######################################
21
  model_name = 'stabilityai/stable-diffusion-2'
 
 
22
  device = ('cpu','cuda')[torch.cuda.is_available()]
23
+ if device == 'cuda':
24
+ revision = 'fp16'
25
+ dtype = torch.float16
26
+ else:
27
+ revision = 'fp32'
28
+ dtype = torch.float32
29
 
30
  # model parameters
31
  better_vae = ''
 
172
  compare_dynamic_guidance,
173
  inputs="text",
174
  outputs=gr.Gallery(),
175
+ title="Comparing image generations with dynamic Classifier-free Guidance",
176
  )
177
  iface.launch()
178