Move external formats to nodes, update dims, merge

External load formats were checked for in utils.extra_config. While this
is a logical place for them to exist, the small size of the file gives
me concern that it could moved or refactored at some point. Instead,
this is now checked fro in nodes

Most of the video formats have dimension restrictions other than 8. Each
has now been updated accordingly.

Merged from origin to resolve the merge conflict locally.
This commit is contained in:
Austin Mroz
2025-01-29 17:24:35 -06:00
3 changed files with 23 additions and 16 deletions
+6 -2
View File
@@ -7,14 +7,18 @@ on:
paths:
- "pyproject.toml"
permissions:
issues: write
jobs:
publish-node:
name: Publish Custom Node to registry
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Kosinkadink' }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Publish Custom Node
uses: Comfy-Org/publish-node-action@main
uses: Comfy-Org/publish-node-action@v1
with:
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github Repository secrets and reference it here.
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github Repository secrets and reference it here.
+9 -6
View File
@@ -39,6 +39,8 @@ class WrappedPreviewer(latent_preview.LatentPreviewer):
self.last_time = self.last_time + num_previews/self.rate
if num_previews > num_images:
num_previews = num_images
elif num_previews <= 0:
return None
if self.first_preview:
self.first_preview = False
serv.send_sync('VHS_latentpreview', {'length':num_images, 'rate': self.rate})
@@ -54,13 +56,14 @@ class WrappedPreviewer(latent_preview.LatentPreviewer):
def process_previews(self, image_tensor, ind, leng):
image_tensor = self.decode_latent_to_preview(image_tensor)
if image_tensor.size(1) > 512 or image_tensor.size(2) > 512:
n = image.size(0)
if image_tensor.size(1) > image_tensor.size(2):
height = (512 * image_tensor.size(2)) // image_tensor.size(1)
image_tensor = F.interpolate(image_tensor, (512,height,3), mode='bilinear')
image_tensor = image_tensor.movedim(-1,0)
if image_tensor.size(2) < image_tensor.size(3):
height = (512 * image_tensor.size(2)) // image_tensor.size(3)
image_tensor = F.interpolate(image_tensor, (height,512), mode='bilinear')
else:
width = (512 * image_tensor.size(1)) // image_tensor.size(2)
image_tensor = F.interpolate(image_tensor, (width, 512,3), mode='bilinear')
width = (512 * image_tensor.size(3)) // image_tensor.size(2)
image_tensor = F.interpolate(image_tensor, (512, width), mode='bilinear')
image_tensor = image_tensor.movedim(0,-1)
previews_ubyte = (((image_tensor + 1.0) / 2.0).clamp(0, 1) # change scale from -1..1 to 0..1
.mul(0xFF) # to 0..255
).to(device="cpu", dtype=torch.uint8)
+8 -8
View File
@@ -11,7 +11,7 @@ import time
import folder_paths
from comfy.utils import common_upscale, ProgressBar
from utils import extra_config
import nodes
from comfy.k_diffusion.utils import FolderOfImages
from .logger import logger
from .utils import BIGMAX, DIMMAX, calculate_file_hash, get_sorted_dir_files_from_directory,\
@@ -24,10 +24,10 @@ video_extensions = ['webm', 'mp4', 'mkv', 'gif', 'mov']
VHSLoadFormats = {
'None': {},
'AnimateDiff': {'target_rate': 8, 'dim': (8,0,512,512)},
'Mochi': {'target_rate': 24, 'dim': (8,0,848,480), 'frames':(6,1)},
'LTXV': {'target_rate': 24, 'dim': (8,0,768,512), 'frames':(8,1)},
'Hunyuan': {'target_rate': 24, 'dim': (8,0,848,480), 'frames':(4,1)},
'Cosmos': {'target_rate': 24, 'dim': (8,0,1280,704), 'frames':(8,1)},
'Mochi': {'target_rate': 24, 'dim': (16,0,848,480), 'frames':(6,1)},
'LTXV': {'target_rate': 24, 'dim': (32,0,768,512), 'frames':(8,1)},
'Hunyuan': {'target_rate': 24, 'dim': (16,0,848,480), 'frames':(4,1)},
'Cosmos': {'target_rate': 24, 'dim': (16,0,1280,704), 'frames':(8,1)},
}
"""
External plugins may add additional formats to utils.extra_config.VHSLoadFormats
@@ -35,13 +35,13 @@ In addition to shorthand options, direct widget names will map a given dict to o
Adding a third arguement to a frames tuple can enable strict checks on number
of loaded frames, i.e (8,1,True)
"""
if not hasattr(extra_config, 'VHSLoadFormats'):
extra_config.VHSLoadFormats = {}
if not hasattr(nodes, 'VHSLoadFormats'):
nodes.VHSLoadFormats = {}
def get_load_formats():
#TODO: check if {**extra_config.VHSLoafFormats, **VHSLoadFormats} has minimum version
formats = {}
formats.update(extra_config.VHSLoadFormats)
formats.update(nodes.VHSLoadFormats)
formats.update(VHSLoadFormats)
return (list(formats.keys()),
{'default': 'AnimateDiff', 'formats': formats})