Instructions to use noamrot/FuseCap_Image_Captioning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use noamrot/FuseCap_Image_Captioning with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="noamrot/FuseCap_Image_Captioning")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("noamrot/FuseCap_Image_Captioning") model = AutoModelForMultimodalLM.from_pretrained("noamrot/FuseCap_Image_Captioning", device_map="auto") - Notebooks
- Google Colab
- Kaggle
fix model weights names
Browse files- pytorch_model.bin +2 -2
- tmp.py +18 -0
pytorch_model.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:34e7263f3e2652f4442fcc014c771d2f775d6d709866a887a82edc8d0703ce84
|
| 3 |
+
size 896058079
|
tmp.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
# Load old model weights
|
| 4 |
+
old_weights = torch.load('/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model.bin', map_location=torch.device('cpu'))
|
| 5 |
+
|
| 6 |
+
# Prepare a dictionary to hold the new weights
|
| 7 |
+
new_weights = {}
|
| 8 |
+
|
| 9 |
+
# Loop over the items in old_weights
|
| 10 |
+
for name, weight in old_weights.items():
|
| 11 |
+
# Replace the old model's layer names with the new model's layer names
|
| 12 |
+
new_name = name.replace('vision_model.encoder.layers', 'visual_encoder.blocks')
|
| 13 |
+
|
| 14 |
+
# Add the modified name and associated weight to new_weights
|
| 15 |
+
new_weights[new_name] = weight
|
| 16 |
+
|
| 17 |
+
# Save the new weights
|
| 18 |
+
torch.save(new_weights, '/Users/snoamr/Documents/superCap/huggingface_model_card/FuseCap/pytorch_model_new.bin')
|