| 215 | |
| 216 | @comfy_node(name="LTXVGemmaCLIPModelLoader", description="Gemma 3 Model Loader") |
| 217 | class LTXVGemmaCLIPModelLoader: |
| 218 | @classmethod |
| 219 | def INPUT_TYPES(s): |
| 220 | return { |
| 221 | "required": { |
| 222 | "gemma_path": ( |
| 223 | folder_paths.get_filename_list("text_encoders"), |
| 224 | {"tooltip": "The name of the text encoder model to load."}, |
| 225 | ), |
| 226 | "ltxv_path": ( |
| 227 | folder_paths.get_filename_list("checkpoints"), |
| 228 | {"tooltip": "The name of the ltxv model to load."}, |
| 229 | ), |
| 230 | "max_length": ( |
| 231 | "INT", |
| 232 | {"default": 1024, "min": 16, "max": 131072, "step": 8}, |
| 233 | ), |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | RETURN_TYPES = ("CLIP",) |
| 238 | RETURN_NAMES = ("clip",) |
| 239 | FUNCTION = "load_model" |
| 240 | CATEGORY = "lightricks/LTXV" |
| 241 | TITLE = "LTXV Gemma CLIP Loader" |
| 242 | OUTPUT_NODE = False |
| 243 | |
| 244 | def load_model(self, gemma_path: str, ltxv_path: str, max_length: int): |
| 245 | path = Path(folder_paths.get_full_path("text_encoders", gemma_path)) |
| 246 | model_root = path.parents[1] |
| 247 | tokenizer_path = Path(find_matching_dir(model_root, "tokenizer.model")) |
| 248 | gemma_model_path = Path(find_matching_dir(model_root, "model*.safetensors")) |
| 249 | processor_path = Path(find_matching_dir(model_root, "preprocessor_config.json")) |
| 250 | tokenizer_class = ltxv_gemma_tokenizer(tokenizer_path, max_length=max_length) |
| 251 | |
| 252 | processor = None |
| 253 | try: |
| 254 | image_processor = AutoImageProcessor.from_pretrained( |
| 255 | str(processor_path), |
| 256 | local_files_only=True, |
| 257 | ) |
| 258 | processor = Gemma3Processor( |
| 259 | image_processor=image_processor, |
| 260 | tokenizer=tokenizer_class().tokenizer, |
| 261 | ) |
| 262 | logger.info(f"Loaded processor from {model_root} - enhancement enabled") |
| 263 | except Exception as e: |
| 264 | logger.warning(f"Could not load processor from {model_root}: {e}") |
| 265 | |
| 266 | clip_dtype = torch.bfloat16 |
| 267 | ltxv_full_path = folder_paths.get_full_path("checkpoints", ltxv_path) |
| 268 | clip_target = comfy.supported_models_base.ClipTarget( |
| 269 | tokenizer=tokenizer_class, |
| 270 | clip=ltxv_gemma_clip( |
| 271 | gemma_model_path, ltxv_full_path, processor=processor, dtype=clip_dtype |
| 272 | ), |
| 273 | ) |
| 274 |
nothing calls this directly
no outgoing calls
no test coverage detected