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") - Notebooks
- Google Colab
- Kaggle
small fix
Browse files
tmp.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 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')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|