JMalott commited on
Commit
42e69b2
·
1 Parent(s): 96ee28d

Update min_dalle/min_dalle.py

Browse files
Files changed (1) hide show
  1. min_dalle/min_dalle.py +15 -16
min_dalle/min_dalle.py CHANGED
@@ -241,23 +241,22 @@ class MinDalle:
241
 
242
  #torch.cuda.empty_cache()
243
  #torch.cpu.empty_cache()
244
- with torch.cpu.amp.autocast(dtype=self.dtype):
245
- image_tokens[i + 1], attention_state = self.decoder.forward(
246
- settings=settings,
247
- attention_mask=attention_mask,
248
- encoder_state=encoder_state,
249
- attention_state=attention_state,
250
- prev_tokens=image_tokens[i],
251
- token_index=token_indices[[i]]
252
- )
253
 
254
- with torch.cpu.amp.autocast(dtype=torch.float32):
255
- if ((i + 1) % 32 == 0 and progressive_outputs) or i + 1 == 256:
256
- yield self.image_grid_from_tokens(
257
- image_tokens=image_tokens[1:].T,
258
- is_seamless=is_seamless,
259
- is_verbose=is_verbose
260
- )
261
 
262
  def generate_image_stream(self, *args, **kwargs) -> Iterator[Image.Image]:
263
  image_stream = self.generate_raw_image_stream(*args, **kwargs)
 
241
 
242
  #torch.cuda.empty_cache()
243
  #torch.cpu.empty_cache()
244
+
245
+ image_tokens[i + 1], attention_state = self.decoder.forward(
246
+ settings=settings,
247
+ attention_mask=attention_mask,
248
+ encoder_state=encoder_state,
249
+ attention_state=attention_state,
250
+ prev_tokens=image_tokens[i],
251
+ token_index=token_indices[[i]]
252
+ )
253
 
254
+ if ((i + 1) % 32 == 0 and progressive_outputs) or i + 1 == 256:
255
+ yield self.image_grid_from_tokens(
256
+ image_tokens=image_tokens[1:].T,
257
+ is_seamless=is_seamless,
258
+ is_verbose=is_verbose
259
+ )
 
260
 
261
  def generate_image_stream(self, *args, **kwargs) -> Iterator[Image.Image]:
262
  image_stream = self.generate_raw_image_stream(*args, **kwargs)