![]() * add init and base image processing functions * add add_fast_image_processor to transformers-cli * add working fast image processor clip * add fast image processor to doc, working tests * remove "to be implemented" SigLip * fix unprotected import * fix unprotected vision import * update ViTImageProcessorFast * increase threshold slow fast ewuivalence * add fast img blip * add fast class in tests with cli * improve cli * add fast image processor convnext * add LlavaPatchingMixin and fast image processor for llava_next and llava_onevision * add device kwarg to ImagesKwargs for fast processing on cuda * cleanup * fix unprotected import * group images by sizes and add batch processing * Add batch equivalence tests, skip when center_crop is used * cleanup * update init and cli * fix-copies * refactor convnext, cleanup base * fix * remove patching mixins, add piped torchvision transforms for ViT * fix unbatched processing * fix f strings * protect imports * change llava onevision to class transforms (test) * fix convnext * improve formatting (following Pavel review) * fix handling device arg * improve cli * fix * fix inits * Add distinction between preprocess and _preprocess, and support for arbitrary kwargs through valid_extra_kwargs * uniformize qwen2_vl fast * fix docstrings * add add fast image processor llava * remove min_pixels max_pixels from accepted size * nit * nit * refactor fast image processors docstrings * cleanup and remove fast class transforms * update add fast image processor transformers cli * cleanup docstring * uniformize pixtral fast and make _process_image explicit * fix prepare image structure llava next/onevision * Use typed kwargs instead of explicit args * nit fix import Unpack * clearly separate pops and gets in base preprocess. Use explicit typed kwargs * make qwen2_vl preprocess arguments hashable |
||
---|---|---|
.. | ||
configuration_dummy.py | ||
configuration_my_new_model.py | ||
configuration_my_new_model2.py | ||
configuration_new_model.py | ||
configuration_super.py | ||
convert_examples.sh | ||
image_processing_new_imgproc_model.py | ||
modeling_add_function.py | ||
modeling_dummy_bert.py | ||
modeling_dummy.py | ||
modeling_from_uppercase_model.py | ||
modeling_multimodal1.py | ||
modeling_multimodal2.py | ||
modeling_my_new_model2.py | ||
modeling_new_task_model.py | ||
modeling_roberta.py | ||
modeling_super.py | ||
modeling_switch_function.py | ||
modular_add_function.py | ||
modular_dummy_bert.py | ||
modular_dummy.py | ||
modular_from_uppercase_model.py | ||
modular_multimodal1.py | ||
modular_multimodal2.py | ||
modular_my_new_model.py | ||
modular_my_new_model2.py | ||
modular_new_imgproc_model.py | ||
modular_new_model.py | ||
modular_new_task_model.py | ||
modular_roberta.py | ||
modular_super.py | ||
modular_switch_function.py | ||
README.md |
Using the modular_converter
linter
pip install libcst
is a must!
sh examples/modular-transformers/convert_examples.sh
to get the converted outputs
The modular converter is a new linter
specific to transformers
. It allows us to unpack inheritance in python to convert a modular file like modular_gemma.py
into a single model single file
.
Examples of possible usage are available in the examples/modular-transformers
, or modular_gemma
for a full model usage.
python utils/modular_model_converter.py --files_to_parse "/Users/arthurzucker/Work/transformers/examples/modular-transformers/modular_my_new_model2.py"
How it works
We use the libcst
parser to produce an AST representation of the modular_xxx.py
file. For any imports that are made from transformers.models.modeling_xxxx
we parse the source code of that module, and build a class dependency mapping, which allows us to unpack the modularerence dependencies.
The code from the modular
file and the class dependency mapping are "merged" to produce the single model single file.
We use ruff to automatically remove the potential duplicate imports.
Why we use libcst instead of the native AST?
AST is super powerful, but it does not keep the docstring
, comment
or code formatting. Thus we decided to go with libcst