argentinian_ids / README.md
Lautaro Suarez
Track large model files with Git LFS
4479560
|
Raw History Blame Contribute Delete
1.28 kB
# Argentinian ID Validation Model
This model was trained to validate Argentinian IDs based on images of the front, back, and invalid IDs. The model uses a ResNet18 architecture and classifies images into three categories: `valid_front`, `valid_back`, and `invalid`.
## Usage
- The model can be loaded in PyTorch using the `.pth` file or in ONNX format for deployment in a variety of environments.
- You can test the model with the `test_model.py` script.
## Files
- `argentinian_id_validation.py`: Code used for training the model.
- `test_model.py`: Script to test the model on new data.
- `dni_image_validation_model.pth`: PyTorch model weights.
- `dni_image_validation_model.onnx`: ONNX version of the model.
## Conversion to ONNX
To convert the PyTorch model to ONNX, the following code was used:
```python
import torch
import torchvision.models as models
model = models.resnet18(pretrained=False)
model.fc = torch.nn.Linear(model.fc.in_features, 3) # 3 classes
model.load_state_dict(torch.load('dni_image_validation_model.pth'))
dummy_input = torch.randn(1, 3, 224, 224) # Input shape
torch.onnx.export(model, dummy_input, "dni_image_validation_model.onnx",
input_names=['input'], output_names=['output'],
opset_version=11)