How to integrate a PyTorch YOLO ensemble model (.pt file) into a Django web app for real-time image predictions?
I'm building a Django web app where users can upload images to detect objects using a YOLO ensemble model saved as a .pt file. This model includes keys like 'model', 'names', 'stride', and 'ensemble_info'. So far, I can load the model with torch.load(), but I'm unsure how to:
Preprocess the uploaded image in a Django view,
Run inference using the loaded ensemble model, and
Return bounding box results to the frontend (ideally as JSON or a drawn image).
Environment: Python 3.10, Django 4.x, Torch 1.13+
Has anyone done something similar, or can you point to an example repo/tutorial? Any help or code snippets would be appreciated!