Instructions to use kd13/Modern-MobileNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kd13/Modern-MobileNet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="kd13/Modern-MobileNet", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained("kd13/Modern-MobileNet", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload configuration_mobilenet.py
Browse files- configuration_mobilenet.py +24 -0
configuration_mobilenet.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
class MobileNetV1Config(PretrainedConfig):
|
| 4 |
+
model_type = "mobilenet_v1_modern"
|
| 5 |
+
|
| 6 |
+
def __init__(
|
| 7 |
+
self,
|
| 8 |
+
num_classes: int = 200,
|
| 9 |
+
block_dropout: float = 0.0,
|
| 10 |
+
final_dropout: float = 0.50,
|
| 11 |
+
**kwargs
|
| 12 |
+
):
|
| 13 |
+
self.num_classes = num_classes
|
| 14 |
+
self.block_dropout = block_dropout
|
| 15 |
+
self.final_dropout = final_dropout
|
| 16 |
+
|
| 17 |
+
# This mapping allows AutoModel to find the code when pushed to the Hub
|
| 18 |
+
if "auto_map" not in kwargs:
|
| 19 |
+
kwargs["auto_map"] = {
|
| 20 |
+
"AutoConfig": "configuration_mobilenet.MobileNetV1Config",
|
| 21 |
+
"AutoModelForImageClassification": "modeling_mobilenet.MobileNetV1ForImageClassification"
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
super().__init__(**kwargs)
|