Shuang59 commited on
Commit
b97fb24
β€’
1 Parent(s): c4bd367

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -52,8 +52,8 @@ model, diffusion = create_model_and_diffusion(**options)
52
  model.eval()
53
  if has_cuda:
54
  model.convert_to_fp16()
55
- model.to(device)
56
- model.load_state_dict(load_checkpoint('base', device))
57
  print('total base parameters', sum(x.numel() for x in model.parameters()))
58
 
59
  # Create upsampler model.
@@ -64,8 +64,8 @@ model_up, diffusion_up = create_model_and_diffusion(**options_up)
64
  model_up.eval()
65
  if has_cuda:
66
  model_up.convert_to_fp16()
67
- model_up.to(device)
68
- model_up.load_state_dict(load_checkpoint('upsample', device))
69
  print('total upsampler parameters', sum(x.numel() for x in model_up.parameters()))
70
 
71
 
@@ -77,6 +77,7 @@ def show_images(batch: th.Tensor):
77
 
78
 
79
  def compose_language_descriptions(prompt, guidance_scale, steps):
 
80
  options['timestep_respacing'] = str(steps)
81
  _, diffusion = create_model_and_diffusion(**options)
82
 
@@ -238,12 +239,13 @@ clevr_model.eval()
238
  if has_cuda:
239
  clevr_model.convert_to_fp16()
240
 
241
- clevr_model.to(device)
242
- clevr_model.load_state_dict(th.load(download_model('clevr_pos'), device))
243
  print('total clevr_pos parameters', sum(x.numel() for x in clevr_model.parameters()))
244
 
245
 
246
  def compose_clevr_objects(prompt, guidance_scale, steps):
 
247
  coordinates = [[float(x.split(',')[0].strip()), float(x.split(',')[1].strip())]
248
  for x in prompt.split('|')]
249
  coordinates += [[-1, -1]] # add unconditional score label
 
52
  model.eval()
53
  if has_cuda:
54
  model.convert_to_fp16()
55
+ model.to(th.device('cpu'))
56
+ model.load_state_dict(load_checkpoint('base', th.device('cpu'))
57
  print('total base parameters', sum(x.numel() for x in model.parameters()))
58
 
59
  # Create upsampler model.
 
64
  model_up.eval()
65
  if has_cuda:
66
  model_up.convert_to_fp16()
67
+ model_up.to(th.device('cpu'))
68
+ model_up.load_state_dict(load_checkpoint('upsample', th.device('cpu')))
69
  print('total upsampler parameters', sum(x.numel() for x in model_up.parameters()))
70
 
71
 
 
77
 
78
 
79
  def compose_language_descriptions(prompt, guidance_scale, steps):
80
+ device = th.device('cpu')
81
  options['timestep_respacing'] = str(steps)
82
  _, diffusion = create_model_and_diffusion(**options)
83
 
 
239
  if has_cuda:
240
  clevr_model.convert_to_fp16()
241
 
242
+ clevr_model.to(th.device('cpu'))
243
+ clevr_model.load_state_dict(th.load(download_model('clevr_pos'), th.device('cpu')))
244
  print('total clevr_pos parameters', sum(x.numel() for x in clevr_model.parameters()))
245
 
246
 
247
  def compose_clevr_objects(prompt, guidance_scale, steps):
248
+ device = th.device('cpu')
249
  coordinates = [[float(x.split(',')[0].strip()), float(x.split(',')[1].strip())]
250
  for x in prompt.split('|')]
251
  coordinates += [[-1, -1]] # add unconditional score label