
# ResNet-50 Model for Central Asian Image Classification

## Model Description

This is a pre-trained ResNet-50 model fine-tuned on the Central Asian Food Dataset. The model is used for image classification across multiple classes. The data was split into training, validation, and test sets. The model was trained using gradient descent with an SGD optimizer and CrossEntropyLoss as the loss function.

## Training Parameters

- **Epochs:** 25
- **Batch Size:** 32
- **Learning Rate:** 0.001
- **Optimizer:** SGD with momentum of 0.9
- **Loss Function:** CrossEntropyLoss

## Results

### Training and Validation, F1

| Stage        | Loss (train) | Accuracy (train) | Loss (val) | Accuracy (val) |
|--------------|--------------|------------------|------------|----------------|
| Epoch 1      | 2.1171       | 47.00%           | 0.8727     | 75.00%         |
| Epoch 2      | 1.0462       | 69.00%           | 0.6721     | 78.00%         |
| ...          | ...          | ...              | ...        | ...            |
| Epoch 25     | 0.4286       | 86.00%           | 0.4349     | 86.00%         |

**Model was trained on two T4 GPUs in a Kaggle notebook trained 36m 7s**  
**Best validation accuracy:** 86,54%
```
                      precision    recall  f1-score   support

            achichuk       0.91      0.98      0.94        41
         airan-katyk       0.84      0.93      0.89        46
                asip       0.78      0.57      0.66        37
            bauyrsak       0.90      0.90      0.90        62
   beshbarmak-w-kazy       0.71      0.84      0.77        44
  beshbarmak-wo-kazy       0.86      0.69      0.76        61
           chak-chak       0.94      0.94      0.94        93
            cheburek       0.92      0.88      0.90        94
        doner-lavash       0.77      1.00      0.87        20
           doner-nan       0.86      0.82      0.84        22
             hvorost       0.98      0.86      0.91       141
            irimshik       0.96      0.94      0.95       175
         kattama-nan       0.84      0.88      0.86        66
          kazy-karta       0.72      0.78      0.75        46
                kurt       0.86      0.97      0.91        61
             kuyrdak       0.92      0.93      0.92        58
       kymyz-kymyran       0.93      0.82      0.87        49
        lagman-fried       0.86      0.95      0.90        38
       lagman-w-soup       0.90      0.80      0.85        75
      lagman-wo-soup       0.58      0.86      0.69        22
               manty       0.91      0.95      0.93        63
               naryn       0.97      0.99      0.98        84
        nauryz-kozhe       0.88      0.96      0.92        52
               orama       0.68      0.84      0.75        38
                plov       0.95      0.98      0.97       101
               samsa       0.91      0.93      0.92       106
    shashlyk-chicken       0.68      0.65      0.66        62
  shashlyk-chicken-v       0.74      0.76      0.75        33
   shashlyk-kuskovoi       0.75      0.75      0.75        71
 shashlyk-kuskovoi-v       0.53      0.79      0.64        29
shashlyk-minced-meat       0.74      0.69      0.72        42
          sheep-head       0.75      0.94      0.83        16
             shelpek       0.77      0.86      0.81        64
              shorpa       0.95      0.88      0.91        80
          soup-plain       0.96      0.94      0.95        71
              sushki       0.83      1.00      0.91        43
               suzbe       0.89      0.82      0.86        62
            taba-nan       0.92      0.80      0.86       136
        talkan-zhent       0.86      0.80      0.83        90
      tushpara-fried       0.79      0.74      0.76        46
     tushpara-w-soup       0.94      0.94      0.94        67
    tushpara-wo-soup       0.92      0.87      0.89        91

            accuracy                           0.87      2698
           macro avg       0.84      0.86      0.85      2698
        weighted avg       0.88      0.87      0.87      2698
```

![confusion matrix](matrix.png)

### Testing

After training, the model was tested on the test set:

- **Test accuracy:** 87%

## Repository Structure

- `main.py` — Code for training and testing the model
- `model/` — Saved model in SafeTensors format

## Usage Instructions

from transformers import AutoModelForImageClassification
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file

repo_id = "Eraly-ml/centraasia-ResNet-50"
filename = "model.safetensors"

# Load model
```
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
model = AutoModelForImageClassification.from_pretrained(repo_id)
model.load_state_dict(load_file(model_path))
```
My telegram @eralyf
achichuk airan-katyk asip bauyrsak beshbarmak-w-kazy beshbarmak-wo-kazy chak-chak cheburek doner-lavash doner-nan hvorost irimshik kattama-nan kazy-karta kurt kuyrdak kymyz-kymyran lagman-fried lagman-w-soup lagman-wo-soup manty naryn nauryz-kozhe orama plov samsa shashlyk-chicken shashlyk-chicken-v shashlyk-kuskovoi shashlyk-kuskovoi-v shashlyk-minced-meat sheep-head shelpek shorpa soup-plain sushki suzbe taba-nan talkan-zhent tushpara-fried tushpara-w-soup tushpara-wo-soup