--- title: Car Classifier emoji: 🚗💨 colorFrom: pink colorTo: purple sdk: gradio sdk_version: 4.0.2 app_file: app.py pinned: false license: apache-2.0 --- Stanford Cars Classification Overview This project focuses on classifying images of cars from the Stanford Cars dataset using a deep learning model implemented with the fastai library. The model is based on the ResNet34 architecture and is trained to recognize various car models. The dataset is divided into training and validation sets, and the training process involves fine-tuning the model to achieve high accuracy. Dataset The dataset used for this project is the Stanford Cars dataset, which contains images of 196 classes of cars. The dataset is divided into a training set and a test set, with corresponding labels provided. Data Exploration To get an overview of the dataset, a random selection of car images is displayed using matplotlib. The images are loaded from the training set, and each image is labeled with its corresponding car model. Data Preprocessing The dataset is prepared for training using the fastai library's DataBlock API. Images are resized to 256x256 pixels, and data augmentation is applied to improve model generalization. The dataset is split into training and validation sets using a random splitter. Model Architecture The image classification model is based on the ResNet34 architecture, a pre-trained model that is fine-tuned on the Stanford Cars dataset. The model is trained using transfer learning to leverage the knowledge gained from a broader image dataset. Training The model is trained in multiple stages. Initially, only the final layers of the pre-trained model are trained. Subsequently, the entire model is unfrozen, and further training is performed. The learning rate is adjusted using learning rate finders to achieve optimal training results. Model Evaluation The model is evaluated on a validation set to measure its performance using metrics such as error rate. The training process involves finding an appropriate learning rate and fine-tuning the model to achieve high accuracy. Inference The trained model is capable of making predictions on new car images. The model is exported and saved as model.pkl for later use. Usage Run the provided Jupyter Notebook code to train the image classification model. Export the trained model as model.pkl. Use the model for image classification by providing image file paths as input to the predict method. Dependencies fastai torchvision scipy matplotlib Feel free to explore, modify, and contribute to this project! If you have any questions or suggestions, please don't hesitate to reach out.