byoussef commited on
Commit
8733a52
1 Parent(s): df8f723

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +96 -0
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - timm
5
+ - TFLite
6
+ - MobileNetV4
7
+ license: apache-2.0
8
+ datasets:
9
+ - imagenet-1k
10
+ pipeline_tag: image-classification
11
+ ---
12
+ # Model card for MobileNetV4_Conv_Small_TFLite_224
13
+
14
+ A MobileNet-V4 image classification model. Trained on ImageNet-1k by Ross Wightman.
15
+
16
+ Converted to TFLite Float32 & Float16 formats by Youssef Boulaouane.
17
+
18
+
19
+ ## Model Details
20
+ - **Pytorch Weights:** https://huggingface.co/timm/mobilenetv4_conv_small.e2400_r224_in1k
21
+ - **Model Type:** Image classification
22
+ - **Model Stats:**
23
+ - Params (M): 3.8
24
+ - GMACs: 0.2
25
+ - Activations (M): 2.0
26
+ - Image size: train = 224 x 224, test = 256 x 256
27
+ - **Dataset:** ImageNet-1k
28
+ - **Papers:**
29
+ - MobileNetV4 -- Universal Models for the Mobile Ecosystem: https://arxiv.org/abs/2404.10518
30
+ - PyTorch Image Models: https://github.com/huggingface/pytorch-image-models
31
+ - **Original:** https://github.com/tensorflow/models/tree/master/official/vision
32
+
33
+ ## Model Usage
34
+ ### Image Classification in Python
35
+ ```python
36
+ import tensorflow as tf
37
+
38
+ # Load label file
39
+ with open('imagenet_classes.txt', 'r') as file:
40
+ lines = file.readlines()
41
+
42
+ index_to_label = {index: line.strip() for index, line in enumerate(lines)}
43
+
44
+ # Initialize interpreter and IO details
45
+ tfl_model = tf.lite.Interpreter(model_path=tf_model_path)
46
+ tfl_model.allocate_tensors()
47
+ input_details = tfl_model.get_input_details()
48
+ output_details = tfl_model.get_output_details()
49
+
50
+ # Load and preprocess the image
51
+ mean = [0.485, 0.456, 0.406]
52
+ std = [0.229, 0.224, 0.225]
53
+
54
+ image = tf.image.resize(
55
+ tf.image.decode_image(tf.io.read_file(image_path), channels=3),
56
+ [256, 256],
57
+ method="bicubic",
58
+ )
59
+ image = tf.image.central_crop(image, central_fraction=224.0/256.0)
60
+ image = (image - mean) / std
61
+
62
+ # Inference and postprocessing
63
+ input = input_details[0]
64
+ tfl_model.set_tensor(input["index"], image)
65
+ tfl_model.invoke()
66
+
67
+ tfl_output = tfl_model.get_tensor(output_details[0]["index"])
68
+ tfl_output_tensor = tf.convert_to_tensor(tfl_output)
69
+ tfl_softmax_output = tf.nn.softmax(tfl_output_tensor, axis=1)
70
+
71
+ tfl_top5_probs, tfl_top5_indices = tf.math.top_k(tfl_softmax_output, k=5)
72
+ ```
73
+
74
+ ### Deployment on Mobile
75
+ Refer to guides available here: https://ai.google.dev/edge/lite/inference
76
+
77
+ ## Citation
78
+ ```bibtex
79
+ @article{qin2024mobilenetv4,
80
+ title={MobileNetV4-Universal Models for the Mobile Ecosystem},
81
+ author={Qin, Danfeng and Leichner, Chas and Delakis, Manolis and Fornoni, Marco and Luo, Shixin and Yang, Fan and Wang, Weijun and Banbury, Colby and Ye, Chengxi and Akin, Berkin and others},
82
+ journal={arXiv preprint arXiv:2404.10518},
83
+ year={2024}
84
+ }
85
+ ```
86
+ ```bibtex
87
+ @misc{rw2019timm,
88
+ author = {Ross Wightman},
89
+ title = {PyTorch Image Models},
90
+ year = {2019},
91
+ publisher = {GitHub},
92
+ journal = {GitHub repository},
93
+ doi = {10.5281/zenodo.4414861},
94
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
95
+ }
96
+ ```