| # Model Card: Gym Machines Image Classifier | |
| ## Dataset Description | |
| The model was trained and evaluated on the `ysakhale/gym-machines-image-dataset`. | |
| This dataset contains images of various gym machines, split into 'original' and 'augmented' subsets. | |
| The augmented subset was used for training and tuning. | |
| ## Intended Use | |
| This model is intended for image classification of gym machines. | |
| It can be used to identify different types of gym equipment from images. | |
| ## Limitations | |
| The model's performance may be limited on images that differ significantly from the training data (e.g., different lighting conditions, angles, or machine types not present in the dataset). | |
| Potential biases in the dataset might affect the model's ability to generalize to certain real-world scenarios. | |
| ## Training Hyperparameters | |
| The following hyperparameters were used for training the AutoGluon MultiModalPredictor: | |
| - presets: "medium_quality" | |
| - model.names: ["timm_image"] | |
| - model.timm_image.checkpoint_name: "resnet18" | |
| ## Evaluation Results | |
| The model was evaluated on the original test set (`df_orig`). | |
| - Accuracy: 62.50% | |
| - Weighted F1: 0.5288 | |
| ## Example Usage | |
| ### Loading from pickled predictor | |
| ```python | |
| import cloudpickle | |
| from huggingface_hub import hf_hub_download | |
| from autogluon.multimodal import MultiModalPredictor | |
| import pandas as pd | |
| model_repo_id = "mohitk24/image_autogluon_predictor" | |
| pkl_filename = "autogluon_image_predictor.pkl" | |
| # Download the pickled predictor | |
| pkl_local_path = hf_hub_download( | |
| repo_id=model_repo_id, | |
| repo_type="model", | |
| filename=pkl_filename, | |
| local_dir="./downloaded_model", | |
| local_dir_use_symlinks=False # Set to True if you prefer symlinks | |
| ) | |
| # Load the predictor from the pickle file | |
| with open(pkl_local_path, "rb") as f: | |
| predictor_from_hub = cloudpickle.load(f) | |
| # Example prediction (replace with your image path or DataFrame) | |
| # Assuming you have a DataFrame 'test_df' with an 'image' column | |
| # results_quick = predictor_from_hub.predict(test_df[["image"]]) | |
| # print(results_quick) | |
| ``` | |
| ### Loading from native AutoGluon directory | |
| ```python | |
| import zipfile | |
| import shutil | |
| from huggingface_hub import hf_hub_download | |
| from autogluon.multimodal import MultiModalPredictor | |
| import pandas as pd | |
| import pathlib | |
| model_repo_id = "mohitk24/image_autogluon_predictor" | |
| zip_filename = "autogluon_image_predictor_dir.zip" | |
| download_dir = pathlib.Path("./downloaded_model_native") | |
| # Download the zipped predictor directory | |
| zip_local_path = hf_hub_download( | |
| repo_id=model_repo_id, | |
| repo_type="model", | |
| filename=zip_filename, | |
| local_dir=str(download_dir), | |
| local_dir_use_symlinks=False # Set to True if you prefer symlinks | |
| ) | |
| # Extract the predictor directory | |
| native_dir = download_dir / "predictor_dir" | |
| if native_dir.exists(): | |
| shutil.rmtree(native_dir) | |
| native_dir.mkdir(parents=True, exist_ok=True) | |
| with zipfile.ZipFile(zip_local_path, "r") as zf: | |
| zf.extractall(str(native_dir)) | |
| # Load the predictor from the native directory | |
| predictor_native = MultiModalPredictor.load(str(native_dir)) | |
| # Example prediction (replace with your image path or DataFrame) | |
| # Assuming you have a DataFrame 'test_df' with an 'image' column | |
| # y_pred_native = predictor_native.predict(test_df[["image"]]) | |
| # print(y_pred_native) | |
| ``` | |
| ## Known Failure Modes | |
| - **Lower performance on original data:** The model was trained on an augmented dataset, which may lead to lower performance on the original, unaugmented images. The evaluation results on the original test set (`df_orig`) reflect this potential drop in performance. | |
| - **Underrepresented classes:** If certain types of gym machines are not well-represented in the training data, the model may struggle to classify them accurately. | |