huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
131.91k stars 26.27k forks source link

sample code in for mobilevitv2 is not working #24763

Closed darwinharianto closed 1 year ago

darwinharianto commented 1 year ago

System Info

Who can help?

No response

Information

Tasks

Reproduction

run sample code from MobileViTV2ForImageClassification

throws an error

ValueError: Unrecognized image processor in apple/mobilevitv2-1.0-imagenet1k-256. Should have a image_processor_type key in its preprocessor_config.json of config.json, or one of the following model_type keys in its config.json: align, beit, bit, blip, blip-2, bridgetower, chinese_clip, clip, clipseg, conditional_detr, convnext, convnextv2, cvt, data2vec-vision, deformable_detr, deit, deta, detr, dinat, donut-swin, dpt, efficientformer, efficientnet, flava, focalnet, git, glpn, groupvit, imagegpt, instructblip, layoutlmv2, layoutlmv3, levit, mask2former, maskformer, mgp-str, mobilenet_v1, mobilenet_v2, mobilevit, mobilevitv2, nat, oneformer, owlvit, perceiver, pix2struct, poolformer, regnet, resnet, sam, segformer, swiftformer, swin, swin2sr, swinv2, table-transformer, timesformer, tvlt, upernet, van, videomae, vilt, vit, vit_hybrid, vit_mae, vit_msn, xclip, yolos

Expected behavior

sample code should not throw an error

ydshieh commented 1 year ago

Hi @darwinharianto

Thank you for opening the issue.

Could you specify which code sample in the link is the exact one that has problem to run? Thank a lot!

amyeroberts commented 1 year ago

@darwinharianto Thanks for reporting this! It seems the issue is coming from the preprocessor config files on the hub for this checkpoint: it points to a class which doesn't exist. If I clone and modify the config file, the image processor will load correctly.

I'll also add this modeling file to our doctests.