Add README.md
Browse files
README.md
CHANGED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Model Card: Gym Machines Image Classifier
|
| 3 |
+
|
| 4 |
+
## Dataset Description
|
| 5 |
+
|
| 6 |
+
The model was trained and evaluated on the `ysakhale/gym-machines-image-dataset`.
|
| 7 |
+
This dataset contains images of various gym machines, split into 'original' and 'augmented' subsets.
|
| 8 |
+
The augmented subset was used for training and tuning.
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
## Intended Use
|
| 12 |
+
|
| 13 |
+
This model is intended for image classification of gym machines.
|
| 14 |
+
It can be used to identify different types of gym equipment from images.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
## Limitations
|
| 18 |
+
|
| 19 |
+
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).
|
| 20 |
+
Potential biases in the dataset might affect the model's ability to generalize to certain real-world scenarios.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## Training Hyperparameters
|
| 24 |
+
|
| 25 |
+
The following hyperparameters were used for training the AutoGluon MultiModalPredictor:
|
| 26 |
+
- presets: "medium_quality"
|
| 27 |
+
- model.names: ["timm_image"]
|
| 28 |
+
- model.timm_image.checkpoint_name: "resnet18"
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
## Evaluation Results
|
| 32 |
+
|
| 33 |
+
The model was evaluated on the original test set (`df_orig`).
|
| 34 |
+
- Accuracy: 62.50%
|
| 35 |
+
- Weighted F1: 0.5288
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
## Example Usage
|
| 39 |
+
### Loading from pickled predictor
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import cloudpickle
|
| 43 |
+
from huggingface_hub import hf_hub_download
|
| 44 |
+
from autogluon.multimodal import MultiModalPredictor
|
| 45 |
+
import pandas as pd
|
| 46 |
+
|
| 47 |
+
model_repo_id = "mohitk24/image_autogluon_predictor"
|
| 48 |
+
pkl_filename = "autogluon_image_predictor.pkl"
|
| 49 |
+
|
| 50 |
+
# Download the pickled predictor
|
| 51 |
+
pkl_local_path = hf_hub_download(
|
| 52 |
+
repo_id=model_repo_id,
|
| 53 |
+
repo_type="model",
|
| 54 |
+
filename=pkl_filename,
|
| 55 |
+
local_dir="./downloaded_model",
|
| 56 |
+
local_dir_use_symlinks=False # Set to True if you prefer symlinks
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
# Load the predictor from the pickle file
|
| 60 |
+
with open(pkl_local_path, "rb") as f:
|
| 61 |
+
predictor_from_hub = cloudpickle.load(f)
|
| 62 |
+
|
| 63 |
+
# Example prediction (replace with your image path or DataFrame)
|
| 64 |
+
# Assuming you have a DataFrame 'test_df' with an 'image' column
|
| 65 |
+
# results_quick = predictor_from_hub.predict(test_df[["image"]])
|
| 66 |
+
# print(results_quick)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Loading from native AutoGluon directory
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
import zipfile
|
| 73 |
+
import shutil
|
| 74 |
+
from huggingface_hub import hf_hub_download
|
| 75 |
+
from autogluon.multimodal import MultiModalPredictor
|
| 76 |
+
import pandas as pd
|
| 77 |
+
import pathlib
|
| 78 |
+
|
| 79 |
+
model_repo_id = "mohitk24/image_autogluon_predictor"
|
| 80 |
+
zip_filename = "autogluon_image_predictor_dir.zip"
|
| 81 |
+
download_dir = pathlib.Path("./downloaded_model_native")
|
| 82 |
+
|
| 83 |
+
# Download the zipped predictor directory
|
| 84 |
+
zip_local_path = hf_hub_download(
|
| 85 |
+
repo_id=model_repo_id,
|
| 86 |
+
repo_type="model",
|
| 87 |
+
filename=zip_filename,
|
| 88 |
+
local_dir=str(download_dir),
|
| 89 |
+
local_dir_use_symlinks=False # Set to True if you prefer symlinks
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
# Extract the predictor directory
|
| 93 |
+
native_dir = download_dir / "predictor_dir"
|
| 94 |
+
if native_dir.exists():
|
| 95 |
+
shutil.rmtree(native_dir)
|
| 96 |
+
native_dir.mkdir(parents=True, exist_ok=True)
|
| 97 |
+
|
| 98 |
+
with zipfile.ZipFile(zip_local_path, "r") as zf:
|
| 99 |
+
zf.extractall(str(native_dir))
|
| 100 |
+
|
| 101 |
+
# Load the predictor from the native directory
|
| 102 |
+
predictor_native = MultiModalPredictor.load(str(native_dir))
|
| 103 |
+
|
| 104 |
+
# Example prediction (replace with your image path or DataFrame)
|
| 105 |
+
# Assuming you have a DataFrame 'test_df' with an 'image' column
|
| 106 |
+
# y_pred_native = predictor_native.predict(test_df[["image"]])
|
| 107 |
+
# print(y_pred_native)
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
## Known Failure Modes
|
| 112 |
+
|
| 113 |
+
- **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.
|
| 114 |
+
- **Underrepresented classes:** If certain types of gym machines are not well-represented in the training data, the model may struggle to classify them accurately.
|
| 115 |
+
|