| --- |
| license: mit |
| language: |
| - en |
| base_model: |
| - facebook/deit-base-patch16-224 |
| --- |
| # DeiT-Classification-Apparel π·οΈπ |
| _A Deep Learning Model for Apparel Image Classification using DeiT_ |
|
|
| ## π Model Overview |
| The **DeiT-Classification-Apparel** model is a **Vision Transformer (DeiT)** trained to classify different types of apparel. It leverages **Data-efficient Image Transformers (DeiT)** for improved image recognition with minimal computational resources. |
|
|
| - **Architecture**: Vision Transformer (DeiT) |
| - **Use Case**: Apparel classification |
| - **Framework**: PyTorch |
| - **Model Size**: 343MB |
| - **Files**: |
| - `DeiT_Model_Parameter.pth` β Trained model weights |
| - `label_encoder.pkl` β Label encoder for class mapping |
|
|
| ## π Files and Usage |
|
|
| ### 1οΈβ£ Load the Model |
| ```python |
| import torch |
| from torchvision import transforms |
| from PIL import Image |
| import pickle |
| |
| # Load Model |
| model = torch.load_state_dict(torch.load("DeiT_Model_Parameter.pth", map_location=device)) |
| model.eval() |
| |
| # Load Label Encoder |
| with open("label_encoder.pkl", "rb") as f: |
| label_encoder = pickle.load(f) |
| ``` |
|
|
| ### 2οΈβ£ Perform Inference |
| ```python |
| def predict(image_path): |
| # Load and preprocess image |
| image = Image.open(image_path).convert("RGB") |
| transform = transforms.Compose([ |
| transforms.Resize((224, 224)), |
| transforms.ToTensor(), |
| ]) |
| input_tensor = transform(image).unsqueeze(0) |
| |
| # Make prediction |
| with torch.no_grad(): |
| output = model(input_tensor) |
| predicted_label = output.argmax(1).item() |
| |
| return label_encoder.inverse_transform([predicted_label])[0] |
| |
| # Example Usage |
| image_path = "sample.jpg" |
| prediction = predict(image_path) |
| print(f"Predicted Apparel: {prediction}") |
| ``` |
|
|
| ## π Applications |
| β
Fashion e-commerce product categorization |
| β
Retail inventory management |
| β
Virtual try-on solutions |
| β
Automated fashion recommendation |
|
|
| ## π οΈ Training Details |
| - **Dataset**: Custom apparel dataset |
| - **Optimizer**: Adam |
| - **Loss Function**: CrossEntropyLoss |
| - **Hardware Used**: NVIDIA T4 GPU |
|
|
| ## π’ Citation |
| If you use this model, please cite: |
| ``` |
| @misc{bobs24_deit_classification_2024, |
| author = {bobs24}, |
| title = {DeiT-Classification-Apparel}, |
| year = {2024}, |
| publisher = {Hugging Face}, |
| howpublished = {\url{https://huggingface.co/bobs24/DeiT-Classification-Apparel}} |
| } |