Views
No views yet
| File | Format | Use |
|---|---|---|
best.pth | PyTorch state dict | training / fine-tuning |
model.torchscript.pt | TorchScript | server / LibTorch |
model_mobile.ptl | TorchScript Lite | iOS / Android (PyTorch Mobile) |
model.onnx | ONNX | Core ML, TFLite (via onnx2tf), ONNX Runtime Mobile |
1import torch, torchvision.transforms as T
2from PIL import Image
3m = torch.jit.load("model.torchscript.pt").eval()
4tf = T.Compose([T.Resize((224,224)), T.ToTensor(),
5 T.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])])
6img = tf(Image.open("food.jpg").convert("RGB")).unsqueeze(0)
7probs = torch.softmax(m(img), dim=-1)[0]
8print({"healthy": probs[0].item(), "unhealthy": probs[1].item()})