Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b35b5d8a17 | ||
|
|
6d5fd74333 | ||
|
|
b705a177d3 | ||
|
|
00fbad37c5 | ||
|
|
6cbe294c1b | ||
|
|
eabe43db79 | ||
|
|
1c99a1c63c | ||
|
|
426cdf5f9f | ||
|
|
5fa3791559 |
@@ -1,4 +1,10 @@
|
||||
# MTB Nodes
|
||||
|
||||
> [!NOTE]
|
||||
> master/main is outdated for now to keep backward compatibility, the next version is being worked on in
|
||||
> [`dev/0.6.0`](https://github.com/melMass/comfy_mtb/tree/dev/0.6.0)
|
||||
|
||||
|
||||
[](https://github.com/melMass/comfy_mtb/actions/workflows/test_embedded.yml)
|
||||
|
||||

|
||||
|
||||
+2
-2
@@ -277,14 +277,14 @@ class MTB_AudioToText(MtbAudio):
|
||||
f"Processing chunk {chunk_offset:.1f}s - {chunk_end / sample_rate:.1f}s"
|
||||
)
|
||||
|
||||
max_length = model.config.max_length or 448
|
||||
max_length = getattr(model.config, "max_length", None) or 448
|
||||
attention_mask = torch.ones((1, max_length))
|
||||
|
||||
input_features = processor(
|
||||
chunk_waveform,
|
||||
sampling_rate=sample_rate,
|
||||
return_tensors="pt",
|
||||
).input_features.to(device)
|
||||
).input_features.to(device=device, dtype=model.dtype)
|
||||
|
||||
with torch.no_grad():
|
||||
predicted_ids = model.generate(
|
||||
|
||||
+4
-4
@@ -335,9 +335,9 @@ class MTB_BatchShape:
|
||||
"image_width": ("INT", {"default": 512}),
|
||||
"image_height": ("INT", {"default": 512}),
|
||||
"shape_size": ("INT", {"default": 100}),
|
||||
"color": ("COLOR", {"default": "#ffffff"}),
|
||||
"bg_color": ("COLOR", {"default": "#000000"}),
|
||||
"shade_color": ("COLOR", {"default": "#000000"}),
|
||||
"color": ("COLOR", {"default": "#ffffff","widgetType": "MTB_COLOR"}),
|
||||
"bg_color": ("COLOR", {"default": "#000000","widgetType": "MTB_COLOR"}),
|
||||
"shade_color": ("COLOR", {"default": "#000000","widgetType": "MTB_COLOR"}),
|
||||
"thickness": ("INT", {"default": 5}),
|
||||
"shadex": ("FLOAT", {"default": 0.0}),
|
||||
"shadey": ("FLOAT", {"default": 0.0}),
|
||||
@@ -842,7 +842,7 @@ class MTB_Batch2dTransform:
|
||||
["edge", "constant", "reflect", "symmetric"],
|
||||
{"default": "edge"},
|
||||
),
|
||||
"constant_color": ("COLOR", {"default": "#000000"}),
|
||||
"constant_color": ("COLOR", {"default": "#000000","widgetType": "MTB_COLOR"}),
|
||||
},
|
||||
"optional": {
|
||||
"x": ("FLOATS",),
|
||||
|
||||
+2
-2
@@ -193,11 +193,11 @@ by default it fallsback to a default font.
|
||||
),
|
||||
"color": (
|
||||
"COLOR",
|
||||
{"default": "black"},
|
||||
{"default": "black", "widgetType": "MTB_COLOR"},
|
||||
),
|
||||
"background": (
|
||||
"COLOR",
|
||||
{"default": "white"},
|
||||
{"default": "white", "widgetType": "MTB_COLOR"},
|
||||
),
|
||||
"h_align": (("left", "center", "right"), {"default": "left"}),
|
||||
"v_align": (("top", "center", "bottom"), {"default": "top"}),
|
||||
|
||||
@@ -683,6 +683,7 @@ class MTB_ImageCompare:
|
||||
|
||||
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
||||
class MTB_LoadImageFromUrl:
|
||||
@@ -698,6 +699,14 @@ class MTB_LoadImageFromUrl:
|
||||
"default": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Example.jpg/800px-Example.jpg"
|
||||
},
|
||||
),
|
||||
"retry_count": (
|
||||
"INT",
|
||||
{"default": 3, "min": 1, "max": 20, "step": 1},
|
||||
),
|
||||
"retry_interval": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "min": 0.0, "max": 60.0, "step": 0.1},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,11 +714,27 @@ class MTB_LoadImageFromUrl:
|
||||
FUNCTION = "load"
|
||||
CATEGORY = "mtb/IO"
|
||||
|
||||
def load(self, url):
|
||||
# get the image from the url
|
||||
image = Image.open(requests.get(url, stream=True).raw)
|
||||
image = ImageOps.exif_transpose(image)
|
||||
return (pil2tensor(image),)
|
||||
def load(self, url, retry_count, retry_interval):
|
||||
# get the image from the url with retry + exponential backoff
|
||||
last_error = None
|
||||
for attempt in range(retry_count):
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
response.raise_for_status()
|
||||
image = Image.open(response.raw)
|
||||
image = ImageOps.exif_transpose(image)
|
||||
return (pil2tensor(image),)
|
||||
except Exception as e:
|
||||
last_error = e
|
||||
if attempt == retry_count - 1:
|
||||
raise
|
||||
wait_seconds = retry_interval * (2**attempt)
|
||||
if wait_seconds > 0:
|
||||
time.sleep(wait_seconds)
|
||||
|
||||
if last_error is not None:
|
||||
raise last_error
|
||||
raise RuntimeError("Failed to load image from URL without captured exception")
|
||||
|
||||
|
||||
class MTB_Blur:
|
||||
@@ -879,8 +904,11 @@ class MTB_MaskToImage:
|
||||
return {
|
||||
"required": {
|
||||
"mask": ("MASK",),
|
||||
"color": ("COLOR",),
|
||||
"background": ("COLOR", {"default": "#000000"}),
|
||||
"color": ("COLOR", {"widgetType": "MTB_COLOR"}),
|
||||
"background": (
|
||||
"COLOR",
|
||||
{"default": "#000000", "widgetType": "MTB_COLOR"},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"invert": ("BOOLEAN", {"default": False}),
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# from ..utils import hex_to_rgb
|
||||
class MTB_ColorInput:
|
||||
RETURN_TYPES = ("COLOR",)
|
||||
FUNCTION = "color"
|
||||
CATEGORY = "mtb/color"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"color": ("MTB_COLOR", {"default": "#ffffff"})},
|
||||
}
|
||||
|
||||
def color(self, color):
|
||||
return (color,)
|
||||
|
||||
|
||||
__nodes__ = [MTB_ColorInput]
|
||||
+1
-1
@@ -34,7 +34,7 @@ class MTB_ImageRemoveBackgroundRembg:
|
||||
),
|
||||
"bgcolor": (
|
||||
"COLOR",
|
||||
{"default": "#000000"},
|
||||
{"default": "#000000","widgetType": "MTB_COLOR"},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ class MTB_ModelPatchSeamless:
|
||||
tilingX,
|
||||
tilingY,
|
||||
):
|
||||
hacked_model = copy.deepcopy(model)
|
||||
hacked_model = model.clone()
|
||||
self.apply_circular(
|
||||
hacked_model.model, startStep, stopStep, tilingX, tilingY
|
||||
)
|
||||
|
||||
+4
-1
@@ -43,7 +43,10 @@ class MTB_TransformImage:
|
||||
["edge", "constant", "reflect", "symmetric"],
|
||||
{"default": "edge"},
|
||||
),
|
||||
"constant_color": ("COLOR", {"default": "#000000"}),
|
||||
"constant_color": (
|
||||
"COLOR",
|
||||
{"default": "#000000", "widgetType": "MTB_COLOR"},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"filter_type": (
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class MTB_LoadVitMatteModel:
|
||||
def execute(self, *, kind: str, autodownload: bool):
|
||||
dest = models_dir / "vitmatte"
|
||||
dest.mkdir(exist_ok=True)
|
||||
name = "dist" if kind == "Distinctions-646" else "com"
|
||||
name = "dis" if kind == "Distinctions-646" else "com"
|
||||
|
||||
file = hf_hub_download(
|
||||
repo_id="melmass/pytorch-scripts",
|
||||
|
||||
+11
-2
@@ -21,7 +21,7 @@ import { infoLogger } from './comfy_shared.js'
|
||||
import { NumberInputWidget } from './numberInput.js'
|
||||
|
||||
// NOTE: new widget types registered by MTB Widgets
|
||||
const newTypes = [/*'BOOL'*/ 'COLOR', 'BBOX']
|
||||
const newTypes = [/*'BOOL'*/ 'COLOR','MTB_COLOR', 'BBOX']
|
||||
|
||||
const deprecated_nodes = {
|
||||
// 'Animation Builder':
|
||||
@@ -739,7 +739,6 @@ const mtb_widgets = {
|
||||
// },
|
||||
|
||||
COLOR: (node, inputName, inputData, _app) => {
|
||||
console.debug('Registering color')
|
||||
return {
|
||||
widget: node.addCustomWidget(
|
||||
MtbWidgets.COLOR(inputName, inputData[1]?.default || '#ff0000'),
|
||||
@@ -748,6 +747,16 @@ const mtb_widgets = {
|
||||
minHeight: 30,
|
||||
}
|
||||
},
|
||||
MTB_COLOR: (node, inputName, inputData, _app) => {
|
||||
return {
|
||||
widget: node.addCustomWidget(
|
||||
MtbWidgets.COLOR(inputName, inputData[1]?.default || '#ff0000'),
|
||||
),
|
||||
minWidth: 150,
|
||||
minHeight: 30,
|
||||
}
|
||||
},
|
||||
|
||||
// BBOX: (node, inputName, inputData, app) => {
|
||||
// console.debug("Registering bbox")
|
||||
// return {
|
||||
|
||||
Reference in New Issue
Block a user