Spaces:
Runtime error
Runtime error
Update min_dalle/min_dalle.py
Browse files- 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 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
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)
|