Skip to content

[Model] Add SLANeXt Model Support - #43707

Merged
vasqu merged 58 commits into
huggingface:mainfrom
liu-jiaxuan:feat/slanext
Mar 20, 2026
Merged

[Model] Add SLANeXt Model Support#43707
vasqu merged 58 commits into
huggingface:mainfrom
liu-jiaxuan:feat/slanext

Conversation

@liu-jiaxuan

Copy link
Copy Markdown
Contributor

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.

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, thanks for the PR! Could you rebase and update a few moments to align with the latest API?

Comment thread docs/source/en/model_doc/slanext.md Outdated
Comment thread docs/source/en/model_doc/slanext.md Outdated
Comment thread docs/source/en/model_doc/slanext.md Outdated
Comment thread docs/source/en/model_doc/slanext.md Outdated
Comment thread src/transformers/models/auto/configuration_auto.py
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/image_processing_slanext.py Outdated
Comment thread utils/check_repo.py Outdated
Comment thread utils/check_repo.py Outdated
Comment thread tests/models/slanext/test_modeling_slanext.py
@zhang-prog

Copy link
Copy Markdown
Contributor

@zucchini-nlp We’ve finished the changes. PTAL.

Discussion:
BaseImageProcessor.resize affects accuracy, because this model uses OpenCV-based resizing during both training and inference. To avoid directly relying on cv2.resize, we implemented a NumPy-based approximation of cv2.resize in the slow image processor to better align with the original accuracy.

However, NumPy-style operations do not seem appropriate for the fast image processor, so we are inclined to think that this model does not need a SLANeXtImageProcessorFast.

What do you think? Also, for the sake of code cleanliness and readability, would it be acceptable to use cv2.resize directly in the slow image processor?

@zucchini-nlp

Copy link
Copy Markdown
Member

What do you think? Also, for the sake of code cleanliness and readability, would it be acceptable to use cv2.resize directly in the slow image processor?

Unfortunately we don't have cv2 in dependencies list, so for slow processor we need to stick to numpy. In Fast processor, we can use numpy and torchvision, does torchvision.F.resize work for you?

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see a few comments not yet resolved, commented there. As for resize, in slow processor we can use PIL and I believe it will work for you case. PIL has all the same resize types as torchvision

Actually we can even delete the slow processor, as fast processor is enough and we're defaulting to load a fast processor anyway. Much easier for you than fixing the code prob

Comment thread src/transformers/models/slanext/modular_slanext.py
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
Comment thread src/transformers/models/slanext/modular_slanext.py Outdated
@vasqu

vasqu commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

@liu-jiaxuan @zhang-prog I pushed my fixes:

  • We need to recheck the integration tests in general and the keys have changed because the base model prefix was wrong
  • I didn't find any usage of self.loc_generator which I commented out and added todo, pls check

@vasqu

vasqu commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

run-slow: slanext

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/slanext"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 8e53663d workflow commit (merge commit)
PR b04e6606 branch commit (from PR)
main e8712550 base commit (on main)

Model CI Report

1 new failed tests from this PR 😭

  • slanext:
    tests/models/slanext/test_modeling_slanext.py::SLANeXtModelIntegrationTest::test_inference_table_recognition_head (✅ ⟹ ❌)

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, slanext

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked locally with our runners, everything passes now! Merging

Thanks a lot @liu-jiaxuan and @zhang-prog for sticking through

@vasqu
vasqu enabled auto-merge March 20, 2026 17:00
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@vasqu
vasqu added this pull request to the merge queue Mar 20, 2026
Merged via the queue into huggingface:main with commit d4f88c2 Mar 20, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants