Spaces:
Sleeping
Sleeping
File size: 643 Bytes
ac38d57 | 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 | import torch
from PIL import Image
import os
import sys
# Ensure backend can be imported
sys.path.append(os.getcwd())
from backend.main import run_pytorch_inference, PYTORCH_MODEL, TRANSFORM
import logging
logging.basicConfig(level=logging.INFO)
def test_timing():
if PYTORCH_MODEL is None:
print("Model not loaded")
return
# Large image to test resizing optimization
img = Image.new('RGB', (2000, 2000), color = 'red')
print("Starting inference...")
result = run_pytorch_inference(img)
print(f"Total Latency in Result: {result['latency_ms']} ms")
if __name__ == "__main__":
test_timing()
|