Skip to content

Update CvT documentation with improved usage examples and additional … #38731

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

Merged
merged 6 commits into from
Jun 17, 2025

Conversation

sezan92
Copy link
Contributor

@sezan92 sezan92 commented Jun 10, 2025

…notes

What does this PR do?

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Rocketknight1
Copy link
Member

cc @stevhliu

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Cool, thanks for your update!

Comment on lines 26 to 28
# TODO: add information about CvT in simple language like Vit
Convolutional Vision Transformer (CvT) is a model that combines the strengths of convolutional neural networks (CNNs) and transformers for computer vision tasks. It introduces convolutional layers into the transformer architecture, allowing it to capture local patterns in images while maintaining the global context provided by self-attention mechanisms.
You can find all the CvT checkpoints under the [Microsoft](https://huggingface.co/microsoft?search_models=cvt) organization.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# TODO: add information about CvT in simple language like Vit
Convolutional Vision Transformer (CvT) is a model that combines the strengths of convolutional neural networks (CNNs) and transformers for computer vision tasks. It introduces convolutional layers into the transformer architecture, allowing it to capture local patterns in images while maintaining the global context provided by self-attention mechanisms.
You can find all the CvT checkpoints under the [Microsoft](https://huggingface.co/microsoft?search_models=cvt) organization.
[Convolutional Vision Transformer (CvT)](https://huggingface.co/papers/2103.15808) is a model that combines the strengths of convolutional neural networks (CNNs) and transformers for computer vision tasks. It introduces convolutional layers into the transformer architecture, allowing it to capture local patterns in images while maintaining the global context provided by self-attention mechanisms.
You can find all the original CvT checkpoints under the [Microsoft](https://huggingface.co/microsoft?search_models=cvt) organization.

- CvT models integrate convolutions into the Vision Transformer architecture, aiming to combine the strengths of both CNNs and Transformers. This can lead to improved performance and efficiency on vision tasks.
- Use [`AutoImageProcessor`] for preprocessing images for CvT models. This typically includes resizing, rescaling, and normalizing the input images to match the model's training configuration.
- The original ViT demo notebooks, such as those found [here](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer), can often be adapted for CvT. You would typically replace ViT-specific classes like `ViTFeatureExtractor` with `AutoImageProcessor` and `ViTForImageClassification` with `CvtForImageClassification` or `AutoModelForImageClassification` using a CvT checkpoint.
- CvT checkpoints available on the Hugging Face Hub are often pre-trained on large-scale datasets like ImageNet-22k and may also be fine-tuned on datasets like ImageNet-1k.

## Resources
Copy link
Member

Choose a reason for hiding this comment

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

Remove the below and replace with:

Refer to this set of ViT [notebooks](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer) for examples of inference and fine-tuning on custom datasets. Replace [`ViTFeatureExtractor`] and [`ViTForImageClassification`] in these notebooks with [`AutoImageProcessor`] and [`CvtForImageClassification`].

@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.

@stevhliu stevhliu marked this pull request as ready for review June 17, 2025 17:25
Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! 🤗

@stevhliu stevhliu merged commit 3ae52cc into huggingface:main Jun 17, 2025
11 checks passed
@sezan92 sezan92 deleted the cvt-model-card-update branch June 18, 2025 01:37
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.

4 participants