File size: 1,448 Bytes
6008691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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)