mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-20 03:10:16 +08:00
Merge branch 'comfyanonymous:master' into master
This commit is contained in:
commit
16d2a4b2e9
@ -1,5 +1,6 @@
|
|||||||
from app.logger import on_flush
|
from app.logger import on_flush
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
class TerminalService:
|
class TerminalService:
|
||||||
@ -10,15 +11,27 @@ class TerminalService:
|
|||||||
self.subscriptions = set()
|
self.subscriptions = set()
|
||||||
on_flush(self.send_messages)
|
on_flush(self.send_messages)
|
||||||
|
|
||||||
|
def get_terminal_size(self):
|
||||||
|
try:
|
||||||
|
size = os.get_terminal_size()
|
||||||
|
return (size.columns, size.lines)
|
||||||
|
except OSError:
|
||||||
|
try:
|
||||||
|
size = shutil.get_terminal_size()
|
||||||
|
return (size.columns, size.lines)
|
||||||
|
except OSError:
|
||||||
|
return (80, 24) # fallback to 80x24
|
||||||
|
|
||||||
def update_size(self):
|
def update_size(self):
|
||||||
sz = os.get_terminal_size()
|
columns, lines = self.get_terminal_size()
|
||||||
changed = False
|
changed = False
|
||||||
if sz.columns != self.cols:
|
|
||||||
self.cols = sz.columns
|
if columns != self.cols:
|
||||||
|
self.cols = columns
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if sz.lines != self.rows:
|
if lines != self.rows:
|
||||||
self.rows = sz.lines
|
self.rows = lines
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
|
|||||||
@ -153,8 +153,7 @@ class BaseModel(torch.nn.Module):
|
|||||||
def encode_adm(self, **kwargs):
|
def encode_adm(self, **kwargs):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def extra_conds(self, **kwargs):
|
def concat_cond(self, **kwargs):
|
||||||
out = {}
|
|
||||||
if len(self.concat_keys) > 0:
|
if len(self.concat_keys) > 0:
|
||||||
cond_concat = []
|
cond_concat = []
|
||||||
denoise_mask = kwargs.get("concat_mask", kwargs.get("denoise_mask", None))
|
denoise_mask = kwargs.get("concat_mask", kwargs.get("denoise_mask", None))
|
||||||
@ -193,7 +192,14 @@ class BaseModel(torch.nn.Module):
|
|||||||
elif ck == "masked_image":
|
elif ck == "masked_image":
|
||||||
cond_concat.append(self.blank_inpaint_image_like(noise))
|
cond_concat.append(self.blank_inpaint_image_like(noise))
|
||||||
data = torch.cat(cond_concat, dim=1)
|
data = torch.cat(cond_concat, dim=1)
|
||||||
out['c_concat'] = comfy.conds.CONDNoiseShape(data)
|
return data
|
||||||
|
return None
|
||||||
|
|
||||||
|
def extra_conds(self, **kwargs):
|
||||||
|
out = {}
|
||||||
|
concat_cond = self.concat_cond(**kwargs)
|
||||||
|
if concat_cond is not None:
|
||||||
|
out['c_concat'] = comfy.conds.CONDNoiseShape(concat_cond)
|
||||||
|
|
||||||
adm = self.encode_adm(**kwargs)
|
adm = self.encode_adm(**kwargs)
|
||||||
if adm is not None:
|
if adm is not None:
|
||||||
@ -523,9 +529,7 @@ class SD_X4Upscaler(BaseModel):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
class IP2P:
|
class IP2P:
|
||||||
def extra_conds(self, **kwargs):
|
def concat_cond(self, **kwargs):
|
||||||
out = {}
|
|
||||||
|
|
||||||
image = kwargs.get("concat_latent_image", None)
|
image = kwargs.get("concat_latent_image", None)
|
||||||
noise = kwargs.get("noise", None)
|
noise = kwargs.get("noise", None)
|
||||||
device = kwargs["device"]
|
device = kwargs["device"]
|
||||||
@ -537,18 +541,15 @@ class IP2P:
|
|||||||
image = utils.common_upscale(image.to(device), noise.shape[-1], noise.shape[-2], "bilinear", "center")
|
image = utils.common_upscale(image.to(device), noise.shape[-1], noise.shape[-2], "bilinear", "center")
|
||||||
|
|
||||||
image = utils.resize_to_batch_size(image, noise.shape[0])
|
image = utils.resize_to_batch_size(image, noise.shape[0])
|
||||||
|
return self.process_ip2p_image_in(image)
|
||||||
|
|
||||||
out['c_concat'] = comfy.conds.CONDNoiseShape(self.process_ip2p_image_in(image))
|
|
||||||
adm = self.encode_adm(**kwargs)
|
|
||||||
if adm is not None:
|
|
||||||
out['y'] = comfy.conds.CONDRegular(adm)
|
|
||||||
return out
|
|
||||||
|
|
||||||
class SD15_instructpix2pix(IP2P, BaseModel):
|
class SD15_instructpix2pix(IP2P, BaseModel):
|
||||||
def __init__(self, model_config, model_type=ModelType.EPS, device=None):
|
def __init__(self, model_config, model_type=ModelType.EPS, device=None):
|
||||||
super().__init__(model_config, model_type, device=device)
|
super().__init__(model_config, model_type, device=device)
|
||||||
self.process_ip2p_image_in = lambda image: image
|
self.process_ip2p_image_in = lambda image: image
|
||||||
|
|
||||||
|
|
||||||
class SDXL_instructpix2pix(IP2P, SDXL):
|
class SDXL_instructpix2pix(IP2P, SDXL):
|
||||||
def __init__(self, model_config, model_type=ModelType.EPS, device=None):
|
def __init__(self, model_config, model_type=ModelType.EPS, device=None):
|
||||||
super().__init__(model_config, model_type, device=device)
|
super().__init__(model_config, model_type, device=device)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 116 KiB |
Loading…
Reference in New Issue
Block a user