Skip to content

Commit 4e8c615

Browse files
committed
minor patches re live preview gens
1 parent 7c756e6 commit 4e8c615

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: docs/Features/Prompt Syntax.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
- Without this, if there are multiple people, it will do a bulk segmented refine on all faces combined
127127
- Note the index order is sorted from leftmost detection to right
128128
- To control the creativity/threshold with a yolo model just append `,<creativity>,<threshold>`, for example `<segment:yolo-face_yolov8m-seg_60.pt-1,0.8,0.25>` sets a `0.8` creativity and `0.25` threshold.
129-
- Note the default "confidence threshold" for Yolo models is `0.25`, which is different than is often used with ClipSeg, and does not have a max value.
129+
- Note the default "confidence threshold" for Yolo models is `0.25`, which is different than is often used with ClipSeg, and does not have a "max threshold" like ClipSeg does.
130130
- If you have a yolo model with multiple supported classes, you can filter specific classes by appending `:<classes>:` to the model name where `<classes>` is a comma-separated list of class IDs or names, e.g., `<segment:yolo-modelnamehere:0,apple,2:,0.8,0.25>`
131131
- There's an advanced parameter under `Regional Prompting` named `Segment Model` to customize the base model used for segment processing
132132
- There's also a parameter named `Save Segment Mask` to save a preview copy of the generated mask

Diff for: src/wwwroot/js/genpage/generatehandler.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class GenerateHandler {
66
this.totalGenRunTime = 0;
77
this.validateModel = true;
88
this.interrupted = -1;
9-
this.socket = null;
9+
this.sockets = {};
1010
this.imageContainerDivId = 'current_image';
1111
this.imageId = 'current_image_img';
1212
this.progressBarHtml = `<div class="image-preview-progress-inner"><div class="image-preview-progress-overall"></div><div class="image-preview-progress-current"></div></div>`;
@@ -116,9 +116,11 @@ class GenerateHandler {
116116
}
117117
return;
118118
}
119+
let socketId = 'normal';
119120
let isPreview = '_preview' in input_overrides;
120121
if (isPreview) {
121122
delete input_overrides['_preview'];
123+
socketId = 'preview';
122124
}
123125
this.beforeGenRun();
124126
let run = () => {
@@ -131,8 +133,8 @@ class GenerateHandler {
131133
let socket = null;
132134
let handleData = data => {
133135
if ('socket_intention' in data && data.socket_intention == 'close') {
134-
if (this.socket == socket) {
135-
this.socket = null;
136+
if (this.sockets[socketId] == socket) {
137+
this.sockets[socketId] = null;
136138
}
137139
if (Object.keys(discardable).length > 0) {
138140
// clear any lingering previews
@@ -267,12 +269,12 @@ class GenerateHandler {
267269
}
268270
this.hadError(e);
269271
};
270-
if (this.socket && this.socket.readyState == WebSocket.OPEN) {
271-
this.socket.send(JSON.stringify(actualInput));
272+
if (this.sockets[socketId] && this.sockets[socketId].readyState == WebSocket.OPEN) {
273+
this.sockets[socketId].send(JSON.stringify(actualInput));
272274
}
273275
else {
274276
socket = makeWSRequestT2I('GenerateText2ImageWS', actualInput, handleData, handleError);
275-
this.socket = socket;
277+
this.sockets[socketId] = socket;
276278
}
277279
};
278280
if (this.validateModel) {

Diff for: src/wwwroot/js/genpage/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ function updateCurrentStatusDirect(data) {
10641064
let estTime = avgGenTime * total;
10651065
timeEstimate = ` (est. ${durationStringify(estTime)})`;
10661066
}
1067-
elem.innerHTML = total == 0 ? (isGeneratingPreviews ? translatableText.get() : '') : `${autoBlock(num_current_gens, 'current generation%')}${autoBlock(num_live_gens, 'running')}${autoBlock(num_backends_waiting, 'queued')}${autoBlock(num_models_loading, waitingOnModelLoadText.get())} ${timeEstimate}...`;
1067+
elem.innerHTML = total == 0 ? (isGeneratingPreviews ? generatingPreviewsText.get() : '') : `${autoBlock(num_current_gens, 'current generation%')}${autoBlock(num_live_gens, 'running')}${autoBlock(num_backends_waiting, 'queued')}${autoBlock(num_models_loading, waitingOnModelLoadText.get())} ${timeEstimate}...`;
10681068
let max = Math.max(num_current_gens, num_models_loading, num_live_gens, num_backends_waiting);
10691069
setPageTitle(total == 0 ? curAutoTitle : `(${max} ${generatingText.get()}) ${curAutoTitle}`);
10701070
}

0 commit comments

Comments
 (0)