do not try to save base64 intermediates in gallery on cancellation

This commit is contained in:
damian0815 2022-11-01 12:54:46 +01:00 committed by Lincoln Stein
parent 4013e8ad6f
commit 7c5305ccba
6 changed files with 536 additions and 845 deletions

View File

@ -642,12 +642,12 @@ class InvokeAIWebServer:
(width, height) = image.size
buffered = io.BytesIO()
image.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue()).decode('UTF-8')
img_base64 = "data:image/jpeg;base64," + img_str
img_base64 = "data:image/jpeg;base64," + base64.b64encode(buffered.getvalue()).decode('UTF-8')
self.socketio.emit(
"intermediateResult",
{
"url": img_base64,
"isBase64": True,
"mtime": 0,
"metadata": {},
"width": width,

File diff suppressed because one or more lines are too long

517
frontend/dist/assets/index.e2832fd4.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>InvokeAI - A Stable Diffusion Toolkit</title>
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
<script type="module" crossorigin src="./assets/index.4488003f.js"></script>
<script type="module" crossorigin src="./assets/index.e2832fd4.js"></script>
<link rel="stylesheet" href="./assets/index.52c8231e.css">
</head>

View File

@ -115,7 +115,8 @@ export declare type Image = {
metadata?: Metadata;
width: number;
height: number;
category: GalleryCategory;
category: GalleryCategory;
isBase64: boolean;
};
// GalleryImages is an array of Image.

View File

@ -261,18 +261,20 @@ const makeSocketIOListeners = (
const { intermediateImage } = getState().gallery;
if (intermediateImage) {
dispatch(
addImage({
category: 'result',
image: intermediateImage,
})
);
dispatch(
addLogEntry({
timestamp: dateFormat(new Date(), 'isoDateTime'),
message: `Intermediate image saved: ${intermediateImage.url}`,
})
);
if (!intermediateImage.isBase64) {
dispatch(
addImage({
category: 'result',
image: intermediateImage,
})
);
dispatch(
addLogEntry({
timestamp: dateFormat(new Date(), 'isoDateTime'),
message: `Intermediate image saved: ${intermediateImage.url}`,
})
);
}
dispatch(clearIntermediateImage());
}