deps: lazy import optional dependencies gguf and torchvision (#4826)

This commit is contained in:
Juwan Yoo
2025-03-27 14:35:36 -07:00
committed by GitHub
parent b39532587b
commit 188105a21b
3 changed files with 25 additions and 3 deletions

View File

@@ -4,7 +4,6 @@ from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple
import torch
import torchvision.transforms as T
from PIL import Image, ImageOps
from transformers import (
AutoProcessor,
@@ -76,6 +75,16 @@ class ImageTransform(object):
self.std = std
self.normalize = normalize
# only load torchvision.transforms when needed
try:
import torchvision.transforms as T
# FIXME: add version check for gguf
except ImportError as err:
raise ImportError(
"Please install torchvision via `pip install torchvision` to use Deepseek-VL2."
) from err
transform_pipelines = [T.ToTensor()]
if normalize: