ShunTay12
Add ViT detector api
3486e63
raw
history blame contribute delete
809 Bytes
"""
Image transforms for the deepfake detector.
"""
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
def get_eval_transforms(processor, model_type="vit"):
"""
Create evaluation transforms based on processor settings.
Args:
processor: The image processor from the model
model_type: Type of model ("vit" or "siglip")
Returns:
Composed transforms for image preprocessing
"""
size = processor.size["height"]
image_mean = processor.image_mean
image_std = processor.image_std
normalize = Normalize(mean=image_mean, std=image_std)
return Compose(
[
Resize(size if model_type == "siglip" else 256),
CenterCrop(size),
ToTensor(),
normalize,
]
)