| --- |
| langauge: en |
| license: mit |
| tags: |
| - image-classification |
| - PyTorch |
| - VehiclesClassification |
| - image preprocessing |
| - Xception |
| inference: true |
| datasets: |
| - AIOmarRehan/Vehicles |
| spaces: |
| - AIOmarRehan/CV_Model_Comparison_in_PyTorch |
| --- |
| |
| ## Models Included |
|
|
| This repository provides three different trained PyTorch models for vehicle image classification: |
|
|
| | File Name | Type | Description | |
| | ----------------------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------- | |
| | `best_model_finetuned_full.pt` | PyTorch `.pt` | Xception model with **two-phase transfer learning**, fine-tuned on the full dataset. Best generalization and accuracy. | |
| | `cnn_model_statedict_20260226_034332.pth` | PyTorch `.pth` | **Custom CNN** trained from scratch. Baseline performance, high variance on unseen data. | |
| | `model.safetensors` | PyTorch `safetensors` | Lightweight **unified CNN model**, faster loading and inference, safe for sharing and reproducible deployment. | |
|
|
| ### How to Load |
|
|
| **PyTorch `.pt` or `.pth`:** |
|
|
| ```python |
| import torch |
| |
| # Load full model |
| model = torch.load("best_model_finetuned_full.pt") |
| model.eval() |
| |
| # Or load CNN state dict |
| cnn_model = CustomCNN(num_classes=7) |
| cnn_model.load_state_dict(torch.load("cnn_model_statedict_20260226_034332.pth")) |
| cnn_model.eval() |
| ``` |
|
|
| **Safetensors:** |
|
|
| ```python |
| from safetensors.torch import load_file |
| |
| state_dict = load_file("model.safetensors") |
| model.load_state_dict(state_dict) |
| model.eval() |
| ``` |