Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ViT export support and image classification #616

Merged
merged 9 commits into from
Jun 3, 2024
Merged

Conversation

JingyaHuang
Copy link
Collaborator

What does this PR do?

Export

  • CLI
optimum-cli export neuron --model facebook/deit-base-patch16-224 --batch_size 1 --task image-classification vit_neuron/
  • API
import requests
from PIL import Image
from transformers import AutoImageProcessor
from optimum.neuron import NeuronModelForImageClassification

# Create the feature extractor and model
model_id = "facebook/deit-base-patch16-224"
feature_extractor = AutoImageProcessor.from_pretrained(model_id)
model = NeuronModelForImageClassification.from_pretrained(model_id, export=True, batch_size=1)
save_directory = "vit_neuron"
model.save_pretrained(save_directory)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@dacorvo dacorvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks four for that neat pull-request !

@JingyaHuang JingyaHuang merged commit a033e04 into main Jun 3, 2024
12 of 14 checks passed
@JingyaHuang JingyaHuang deleted the add-vit-support branch June 3, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants