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>
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
import torch
|
|
|
|
|
|
QWEN3_VL_MODELS = {
|
|
"Qwen3-VL-2B-Instruct": "Qwen/Qwen3-VL-2B-Instruct",
|
|
"Qwen3-VL-4B-Instruct": "Qwen/Qwen3-VL-4B-Instruct",
|
|
"Qwen3-VL-8B-Instruct": "Qwen/Qwen3-VL-8B-Instruct",
|
|
"Qwen3-VL-32B-Instruct": "Qwen/Qwen3-VL-32B-Instruct",
|
|
"Qwen3-VL-30B-A3B-Instruct": "Qwen/Qwen3-VL-30B-A3B-Instruct",
|
|
}
|
|
|
|
|
|
def model_names():
|
|
return list(QWEN3_VL_MODELS.keys())
|
|
|
|
|
|
def resolve_model_id(model_variant, custom_model_id):
|
|
custom_model_id = (custom_model_id or "").strip()
|
|
if custom_model_id:
|
|
return custom_model_id
|
|
return QWEN3_VL_MODELS[model_variant]
|
|
|
|
|
|
def dtype_options():
|
|
options = ["auto", "bfloat16", "float16", "float32"]
|
|
if torch.cuda.is_available() and torch.cuda.is_bf16_supported():
|
|
return options
|
|
return ["auto", "float16", "float32"]
|
|
|
|
|
|
def dtype_from_name(dtype_name):
|
|
if dtype_name == "auto":
|
|
return "auto"
|
|
return {
|
|
"bfloat16": torch.bfloat16,
|
|
"float16": torch.float16,
|
|
"float32": torch.float32,
|
|
}[dtype_name]
|
|
|
|
|
|
def device_map_options():
|
|
if torch.cuda.is_available():
|
|
return ["auto", "cuda", "cpu"]
|
|
return ["cpu", "auto"]
|
|
|
|
|
|
def attention_options():
|
|
return ["sdpa", "flash_attention_2", "eager"]
|