reduce mandatory requirements

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2026-02-18 17:53:08 +01:00
parent d6bbfe3dc2
commit 6fdd3a53cf
55 changed files with 120 additions and 103 deletions
+10 -5
View File
@@ -1,7 +1,12 @@
import importlib
from typing import Any, Callable, List, Union
from omegaconf import DictConfig, ListConfig, OmegaConf
try:
from installer import install
install('omegaconf')
from omegaconf import DictConfig, ListConfig, OmegaConf
except Exception as e:
raise ImportError(f"Failed to import omegaconf. Error: {e}") from e
try:
OmegaConf.register_new_resolver("eval", eval)
@@ -10,7 +15,7 @@ except Exception as e:
raise
def load_config(path: str, argv: List[str] = None) -> Union[DictConfig, ListConfig]:
def load_config(path: str, argv: List[str] = None):
"""
Load a configuration. Will resolve inheritance.
"""
@@ -25,7 +30,7 @@ def load_config(path: str, argv: List[str] = None) -> Union[DictConfig, ListConf
def resolve_recursive(
config: Any,
resolver: Callable[[Union[DictConfig, ListConfig]], Union[DictConfig, ListConfig]],
resolver: Callable[[Any], Any],
) -> Any:
config = resolver(config)
if isinstance(config, DictConfig):
@@ -41,7 +46,7 @@ def resolve_recursive(
return config
def resolve_inheritance(config: Union[DictConfig, ListConfig]) -> Any:
def resolve_inheritance(config: Any) -> Any:
"""
Recursively resolve inheritance if the config contains:
__inherit__: path/to/parent.yaml or a ListConfig of such paths.
@@ -104,7 +109,7 @@ def import_item(path: Union[str, List[str]], name: str) -> Any:
raise ValueError(f"Path must be string or list of strings, got: {type(path)}")
def create_object(config: DictConfig) -> Any:
def create_object(config: Any) -> Any:
"""
Create an object from config.
The config is expected to contains the following:
@@ -17,7 +17,6 @@ Utility functions for creating schedules and samplers from config.
"""
import torch
from omegaconf import DictConfig
from .samplers.base import Sampler
from .samplers.euler import EulerSampler
@@ -28,7 +27,7 @@ from .timesteps.sampling.trailing import UniformTrailingSamplingTimesteps
def create_schedule_from_config(
config: DictConfig,
config,
) -> Schedule:
"""
Create a schedule from configuration.
@@ -40,7 +39,7 @@ def create_schedule_from_config(
def create_sampler_from_config(
config: DictConfig,
config,
schedule: Schedule,
timesteps: SamplingTimesteps,
) -> Sampler:
@@ -57,7 +56,7 @@ def create_sampler_from_config(
def create_sampling_timesteps_from_config(
config: DictConfig,
config,
schedule: Schedule,
device: torch.device,
) -> SamplingTimesteps:
+6 -2
View File
@@ -1,7 +1,6 @@
from typing import List, Optional, Tuple, Union
import torch
from einops import rearrange
from omegaconf import DictConfig, ListConfig
from ..common.diffusion import classifier_free_guidance_dispatcher, create_sampler_from_config, create_sampling_timesteps_from_config, create_schedule_from_config
from ..models.dit_v2 import na
@@ -40,7 +39,9 @@ def optimized_channels_to_second(tensor):
class VideoDiffusionInfer():
def __init__(self, config: DictConfig, device: str, dtype: torch.dtype):
def __init__(self, config, device: str, dtype: torch.dtype):
from installer import install
install('omegaconf')
self.config = config
self.device = device
self.dtype = dtype
@@ -48,6 +49,7 @@ class VideoDiffusionInfer():
self.dit = None
self.sampler = None
self.schedule = None
def get_condition(self, latent: torch.Tensor, latent_blur: torch.Tensor, task: str) -> torch.Tensor:
t, h, w, c = latent.shape
cond = torch.zeros([t, h, w, c + 1], device=latent.device, dtype=latent.dtype)
@@ -93,6 +95,7 @@ class VideoDiffusionInfer():
@torch.no_grad()
def vae_encode(self, samples: List[torch.Tensor]) -> List[torch.Tensor]:
from omegaconf import ListConfig
use_sample = self.config.vae.get("use_sample", True)
latents = []
if len(samples) > 0:
@@ -138,6 +141,7 @@ class VideoDiffusionInfer():
@torch.no_grad()
def vae_decode(self, latents: List[torch.Tensor], target_dtype: torch.dtype = None) -> List[torch.Tensor]:
"""🚀 VAE decode optimisé - décodage direct sans chunking, compatible avec autocast externe"""
from omegaconf import ListConfig
samples = []
if len(latents) > 0:
device = self.device
+4 -1
View File
@@ -1,6 +1,5 @@
import os
import torch
from omegaconf import OmegaConf
from safetensors.torch import load_file as load_safetensors_file
from huggingface_hub import hf_hub_download
from ..optimization.memory_manager import preinitialize_rope_cache
@@ -9,6 +8,10 @@ from ..core.infer import VideoDiffusionInfer
def configure_runner(model_name, cache_dir, device:str='cpu', dtype:torch.dtype=None):
from installer import install
install('omegaconf')
from omegaconf import OmegaConf
repo_id = "vladmandic/SeedVR2"
script_directory = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
config_path = os.path.join(script_directory, './config_7b.yaml') if "7b" in model_name else os.path.join(script_directory, './config_3b.yaml')