Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b35b5d8a17 | ||
|
|
6d5fd74333 | ||
|
|
b705a177d3 | ||
|
|
00fbad37c5 | ||
|
|
6cbe294c1b |
@@ -1,8 +1,8 @@
|
|||||||
# MTB Nodes
|
# MTB Nodes
|
||||||
|
|
||||||
> [!CAUTION]
|
> [!NOTE]
|
||||||
> A lot of recent changes to comfy broke many things in mtb (colors, dynamic inputs and probably more)
|
> 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) partially address these. My time is limited lately so it might take time to finish and merge
|
> [`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)
|
[](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"
|
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))
|
attention_mask = torch.ones((1, max_length))
|
||||||
|
|
||||||
input_features = processor(
|
input_features = processor(
|
||||||
chunk_waveform,
|
chunk_waveform,
|
||||||
sampling_rate=sample_rate,
|
sampling_rate=sample_rate,
|
||||||
return_tensors="pt",
|
return_tensors="pt",
|
||||||
).input_features.to(device)
|
).input_features.to(device=device, dtype=model.dtype)
|
||||||
|
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
predicted_ids = model.generate(
|
predicted_ids = model.generate(
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ class MTB_ImageCompare:
|
|||||||
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class MTB_LoadImageFromUrl:
|
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"
|
"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"
|
FUNCTION = "load"
|
||||||
CATEGORY = "mtb/IO"
|
CATEGORY = "mtb/IO"
|
||||||
|
|
||||||
def load(self, url):
|
def load(self, url, retry_count, retry_interval):
|
||||||
# get the image from the url
|
# get the image from the url with retry + exponential backoff
|
||||||
image = Image.open(requests.get(url, stream=True).raw)
|
last_error = None
|
||||||
image = ImageOps.exif_transpose(image)
|
for attempt in range(retry_count):
|
||||||
return (pil2tensor(image),)
|
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:
|
class MTB_Blur:
|
||||||
|
|||||||
+1
-1
@@ -145,7 +145,7 @@ class MTB_ModelPatchSeamless:
|
|||||||
tilingX,
|
tilingX,
|
||||||
tilingY,
|
tilingY,
|
||||||
):
|
):
|
||||||
hacked_model = copy.deepcopy(model)
|
hacked_model = model.clone()
|
||||||
self.apply_circular(
|
self.apply_circular(
|
||||||
hacked_model.model, startStep, stopStep, tilingX, tilingY
|
hacked_model.model, startStep, stopStep, tilingX, tilingY
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ class MTB_LoadVitMatteModel:
|
|||||||
def execute(self, *, kind: str, autodownload: bool):
|
def execute(self, *, kind: str, autodownload: bool):
|
||||||
dest = models_dir / "vitmatte"
|
dest = models_dir / "vitmatte"
|
||||||
dest.mkdir(exist_ok=True)
|
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(
|
file = hf_hub_download(
|
||||||
repo_id="melmass/pytorch-scripts",
|
repo_id="melmass/pytorch-scripts",
|
||||||
|
|||||||
Reference in New Issue
Block a user