Instructions to use fancyfeast/so400m-long with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fancyfeast/so400m-long with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="fancyfeast/so400m-long") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotImageClassification processor = AutoProcessor.from_pretrained("fancyfeast/so400m-long") model = AutoModelForZeroShotImageClassification.from_pretrained("fancyfeast/so400m-long") - Notebooks
- Google Colab
- Kaggle
Text model weight names cause error in loading.
First, thank you for doing this! Super cool and I am experimenting with it. I wanted to bring to your attention that the text model weight keys are
text_model.text_model.embeddings.position_embedding.weight
vs
text_model.embeddings.position_embedding.weight
There is an extra text_model on all the weights that prevents it from loading with transformers.
Thank you for pointing that out! I goofed on the checkpoint conversion. Should be fixed now. Though no guarantee the model works correctly; I'll have to get back to this project in the future and double check everything.
Another issue I ran into is transformers complaining about max_length not being specified, even though it's in the tokenizer's config. So I had to run with: inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt", truncation=True, max_length=256)