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

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

No files matched your search

+10 -1
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: