Download inference.py from ByteJoseph/realtime-digit-draw: direct link, hf CLI and curl.
- Browser
- Download file 248 Bytes
-
https://huggingface.co/ByteJoseph/realtime-digit-draw/resolve/main/inference.py
- Command line
-
hf download hf://ByteJoseph/realtime-digit-draw/inference.py
-
curl -L -o inference.py https://huggingface.co/ByteJoseph/realtime-digit-draw/resolve/main/inference.py
248 Bytes
| import torch | |
| from model import ANN | |
| model = ANN() | |
| model.load_state_dict(torch.load("weights.pth", map_location="cpu")) | |
| model.eval() | |
| def predict(image_tensor): | |
| with torch.no_grad(): | |
| return model(image_tensor).argmax(1).item() | |