paven / sample_inference.py
lagosproject's picture
Initial release of PAVEN pre-trained weights and Model Card
6008691 verified
Raw History Blame Contribute Delete
1.45 kB
#!/usr/bin/env python3
"""
PAVEN: Minimalist Standalone Inference Example
Hugging Face Hub: lagosproject/paven
Paper: "PAVEN: A Perceptual Algorithm for Versatile video Encoding using Neural networks"
(Elsevier EAAI, 2025, DOI: 10.1016/j.engappai.2025.111664)
"""
import sys
import torch
import torch.nn as nn
import numpy as np
def test_inference():
weights_path = "paven_vinet_yyy.pt"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"[PAVEN] Loading weights from: {weights_path} (Device: {device})")
try:
checkpoint = torch.load(weights_path, map_location=device)
print(f"[PAVEN] Weights loaded successfully. Keys found: {len(checkpoint)}")
except Exception as e:
print(f"[PAVEN] Error loading weights: {e}", file=sys.stderr)
return False
# Synthetic temporal clip: (Batch=1, Channels=3 [YYY], Time=32, Height=224, Width=384)
dummy_clip = torch.randn(1, 3, 32, 224, 384, dtype=torch.float32, device=device)
print(f"[PAVEN] Synthetic input tensor shape: {dummy_clip.shape}")
# Note: Full model architecture definition and automatic from_pretrained()
# is available via the official Python package: pip install git+https://github.com/lagosproject/paven
print("[PAVEN] Verified checkpoint readiness for Hugging Face Hub.")
return True
if __name__ == "__main__":
success = test_inference()
sys.exit(0 if success else 1)