Files
FillipandClaude Opus 4.7 3c04bdc186 Initial release: FL VLM nodes for ComfyUI
Adds two nodes (FL VLM Model Loader, FL VLM Image Inference) with a
Qwen3-VL backend, optional 8-bit/4-bit quantization, resize presets,
per-image or shared-prompt batch modes, and a streaming progress UI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-12 10:46:15 -07:00

38 lines
970 B
Python

import json
import uuid
from pathlib import Path
import numpy as np
from PIL import Image
import folder_paths
def comfy_batch_to_temp_images(image_batch, prefix="fl_vlm"):
if image_batch is None:
raise ValueError("FL VLM Image Inference requires an IMAGE input.")
temp_dir = Path(folder_paths.temp_directory) / "fl_vlm"
temp_dir.mkdir(parents=True, exist_ok=True)
paths = []
for idx in range(int(image_batch.shape[0])):
array = image_batch[idx].detach().cpu().numpy()
array = np.clip(array * 255.0, 0, 255).astype(np.uint8)
path = temp_dir / f"{prefix}_{idx}_{uuid.uuid4().hex}.png"
Image.fromarray(array).save(path)
paths.append(path)
return paths
def remove_temp_images(paths):
for path in paths:
try:
Path(path).unlink(missing_ok=True)
except Exception:
pass
def compact_json(data):
return json.dumps(data, ensure_ascii=False, indent=2)