JMalott commited on
Commit
7067210
1 Parent(s): d5d9649

Update min_dalle/min_dalle.py

Browse files
Files changed (1) hide show
  1. min_dalle/min_dalle.py +22 -19
min_dalle/min_dalle.py CHANGED
@@ -238,26 +238,29 @@ class MinDalle:
238
  if(st.session_state.page != 0):
239
  break
240
  st.session_state.bar.progress(i/IMAGE_TOKEN_COUNT)
241
-
242
- #torch.cuda.empty_cache()
243
- #torch.cpu.empty_cache()
244
- #with torch.cuda.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.cuda.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)
 
238
  if(st.session_state.page != 0):
239
  break
240
  st.session_state.bar.progress(i/IMAGE_TOKEN_COUNT)
241
+
242
+ try:
243
+ #torch.cuda.empty_cache()
244
+ #torch.cpu.empty_cache()
245
+ #with torch.cuda.amp.autocast(dtype=self.dtype):
246
+ image_tokens[i + 1], attention_state = self.decoder.forward(
247
+ settings=settings,
248
+ attention_mask=attention_mask,
249
+ encoder_state=encoder_state,
250
+ attention_state=attention_state,
251
+ prev_tokens=image_tokens[i],
252
+ token_index=token_indices[[i]]
 
 
 
 
 
 
 
253
  )
254
+
255
+ # with torch.cuda.amp.autocast(dtype=torch.float32):
256
+ if ((i + 1) % 32 == 0 and progressive_outputs) or i + 1 == 256:
257
+ yield self.image_grid_from_tokens(
258
+ image_tokens=image_tokens[1:].T,
259
+ is_seamless=is_seamless,
260
+ is_verbose=is_verbose
261
+ )
262
+ except Exception as e
263
+ print(e)
264
 
265
  def generate_image_stream(self, *args, **kwargs) -> Iterator[Image.Image]:
266
  image_stream = self.generate_raw_image_stream(*args, **kwargs)