riccardomusmeci
commited on
Commit
•
a2a4440
1
Parent(s):
f8bea65
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
library_name: mlx-image
|
4 |
+
tags:
|
5 |
+
- mlx
|
6 |
+
- mlx-image
|
7 |
+
- vision
|
8 |
+
- image-classification
|
9 |
+
datasets:
|
10 |
+
- imagenet-1k
|
11 |
+
---
|
12 |
+
# regnet_x_16gf
|
13 |
+
|
14 |
+
A RegNetX-16GF image classification model. Pretrained in ImageNet by torchvision contributors (see ImageNet1K-V2 weight details https://github.com/pytorch/vision/issues/3995#new-recipe).
|
15 |
+
|
16 |
+
Disclaimer: This is a porting of the torch model weights to Apple MLX Framework.
|
17 |
+
|
18 |
+
## How to use
|
19 |
+
```bash
|
20 |
+
pip install mlx-image
|
21 |
+
```
|
22 |
+
|
23 |
+
Here is how to use this model for image classification:
|
24 |
+
|
25 |
+
```python
|
26 |
+
from mlxim.model import create_model
|
27 |
+
from mlxim.io import read_rgb
|
28 |
+
from mlxim.transform import ImageNetTransform
|
29 |
+
|
30 |
+
transform = ImageNetTransform(train=False, img_size=224)
|
31 |
+
x = transform(read_rgb("cat.png"))
|
32 |
+
x = mx.expand_dims(x, 0)
|
33 |
+
|
34 |
+
model = create_model("regnet_x_16gf")
|
35 |
+
model.eval()
|
36 |
+
|
37 |
+
logits = model(x)
|
38 |
+
```
|
39 |
+
|
40 |
+
You can also use the embeds from layer before head:
|
41 |
+
```python
|
42 |
+
from mlxim.model import create_model
|
43 |
+
from mlxim.io import read_rgb
|
44 |
+
from mlxim.transform import ImageNetTransform
|
45 |
+
|
46 |
+
transform = ImageNetTransform(train=False, img_size=224)
|
47 |
+
x = transform(read_rgb("cat.png"))
|
48 |
+
x = mx.expand_dims(x, 0)
|
49 |
+
|
50 |
+
# first option
|
51 |
+
model = create_model("regnet_x_16gf", num_classes=0)
|
52 |
+
model.eval()
|
53 |
+
|
54 |
+
embeds = model(x)
|
55 |
+
|
56 |
+
# second option
|
57 |
+
model = create_model("regnet_x_16gf")
|
58 |
+
model.eval()
|
59 |
+
|
60 |
+
embeds = model.get_features(x)
|
61 |
+
```
|
62 |
+
|