This commit is contained in:
Chris
2025-05-01 14:04:06 +10:00
parent c895b0abb7
commit 3f3846a1c1
3 changed files with 15 additions and 14 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ class ImageFilter(PreviewImage):
if video_frames>1:
images_to_return = [ key*video_frames + frm for key in images_to_return for frm in range(video_frames) ]
images = torch.stack(list(images[i] for i in images_to_return))
images = torch.stack(list(images[int(i)] for i in images_to_return))
latents = {"samples": torch.stack(list(latents['samples'][i] for i in images_to_return))} if latents is not None else None
masks = torch.stack(list(masks[i] for i in images_to_return)) if masks is not None else None
+9 -9
View File
@@ -3,7 +3,6 @@ from aiohttp import web
from comfy.model_management import InterruptProcessingException, throw_exception_if_processing_interrupted
import time, json
from typing import Optional
from dataclasses import dataclass
REQUEST_RESHOW = "-1"
REQUEST_TIMER_RESET = "-2"
@@ -12,16 +11,17 @@ WAITING_FOR_RESPONSE = "-9"
SPECIALS = [REQUEST_RESHOW, REQUEST_TIMER_RESET, CANCEL, WAITING_FOR_RESPONSE]
@dataclass
class Response:
selection: Optional[list[int]] = None
text: Optional[str] = None
masked_image: Optional[str] = None
extras: Optional[list[str]] = []
timeout = False
def __init__(self, selection:Optional[list[int]] = None, text:Optional[str] = None,
masked_image:Optional[str] = None, extras:Optional[list[str]] = None):
self.selection = selection
self.text = text
self.masked_image = masked_image
self.extras = extras
self.timeout = False
def get_extras(self,defaults:list[str]) -> list[str]:
return self.extras or defaults
return self.extras or defaults
class TimeoutResponse(Response):
def __init__(self):
@@ -71,7 +71,7 @@ async def cg_image_filter_message(request):
elif (message.real and not MessageState.cancelled()):
MessageState.latest = message
else:
print(f"Ignoring response {response} as current response is {MessageState.response}")
print(f"Ignoring response {response}")
return web.json_response({})
+5 -4
View File
@@ -47,7 +47,7 @@ class State {
State.visible(popup.floating_window, (state==State.FILTER || state==State.ZOOMED || state==State.TEXT || state==State.MASK))
State.visible(popup.button_row, state!=State.MASK)
State.disabled(popup.send_button, (state==State.FILTER || state==State.ZOOMED) && popup.picked.length==0)
State.disabled(popup.send_button, (state==State.FILTER || state==State.ZOOMED) && popup.picked.size==0)
State.visible(popup.extras_row, popup.n_extras>0)
State.visible(popup.tip_row, popup.tip_row.innerHTML.length>0)
State.visible(popup.text_edit, state==State.TEXT)
@@ -141,7 +141,7 @@ class Popup extends HTMLSpanElement {
msg.extras = []
Array.from(this.extras_row.children).forEach((e)=>{ msg.extras.push(e.value) })
}
if (this.state==State.FILTER || this.state==State.ZOOMED) msg.selection = this.picked
if (this.state==State.FILTER || this.state==State.ZOOMED) msg.selection = Array.from(this.picked)
if (this.state==State.TEXT) msg.text = this.text_edit.value
this.last_response_sent = Date.now()
@@ -211,8 +211,6 @@ class Popup extends HTMLSpanElement {
}
this.node = node
this.allsame = message.detail.allsame || false
this.n_extras = message.detail.extras ? message.detail.extras.length : 0
if (this.state==State.INACTIVE && message.detail.urls && app.ui.settings.getSettingValue("ImageFilter.SmallWindow") && !use_saved && !this.autosend()) {
this.state = State.TINY
@@ -240,6 +238,9 @@ class Popup extends HTMLSpanElement {
return `Timeout`
}
this.allsame = detail.allsame || false
this.n_extras = detail.extras ? message.detail.extras.length : 0
this.set_title(detail)
if (!use_saved && !this.autosend()) this.maybe_play_sound()