Added model.bin
Browse files- convert_safetensors_to_bin.py +15 -0
- sagvit.bin +3 -0
- test_model_loading.py +2 -7
convert_safetensors_to_bin.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from safetensors.torch import load_file
|
3 |
+
from transformers import AutoConfig, AutoModel
|
4 |
+
|
5 |
+
# Path to your safetensors file
|
6 |
+
safetensors_path = "model.safetensors"
|
7 |
+
bin_path = "sagvit.bin"
|
8 |
+
|
9 |
+
# Load model weights from safetensors
|
10 |
+
state_dict = load_file(safetensors_path)
|
11 |
+
|
12 |
+
# Save as pytorch_model.bin
|
13 |
+
torch.save(state_dict, bin_path)
|
14 |
+
|
15 |
+
print(f"Converted {safetensors_path} to {bin_path}.")
|
sagvit.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff3f3f603954fd987783ae22320d9e941ddb1e53acb9ce5b341d8911bdf3d100
|
3 |
+
size 27102094
|
test_model_loading.py
CHANGED
@@ -1,11 +1,6 @@
|
|
1 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
2 |
-
from safetensors import safe_open
|
3 |
|
4 |
-
model = AutoModelForImageClassification.from_pretrained(
|
5 |
-
|
6 |
-
use_safetensors=True, # Enable safetensors
|
7 |
-
trust_remote_code=True
|
8 |
-
)
|
9 |
-
processor = AutoImageProcessor.from_pretrained("shravvvv/SAG-ViT", use_safetensors=True, trust_remote_code=True)
|
10 |
|
11 |
print(model)
|
|
|
1 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
|
2 |
|
3 |
+
model = AutoModelForImageClassification.from_pretrained("shravvvv/SAG-ViT", trust_remote_code=True)
|
4 |
+
processor = AutoImageProcessor.from_pretrained("shravvvv/SAG-ViT", trust_remote_code=True)
|
|
|
|
|
|
|
|
|
5 |
|
6 |
print(model)
|