Skip to content

Add glpn fast processor#38461

Closed
aryanchauhan31 wants to merge 3 commits into
huggingface:mainfrom
aryanchauhan31:add-glpn-fast-processor
Closed

Add glpn fast processor#38461
aryanchauhan31 wants to merge 3 commits into
huggingface:mainfrom
aryanchauhan31:add-glpn-fast-processor

Conversation

@aryanchauhan31

Copy link
Copy Markdown
Contributor

This PR adds support for GLPNImageProcessorFast, enabling fast inference for the GLPN model using TorchVision backends.

Changes:

  • Added GLPNImageProcessorFast implementation in image_processing_glpn_fast.py.
  • Updated __init__.py to include the new fast processor in import_structure.
  • Verified functional equivalence with the slow processor (max abs diff < 1e-7).
  • Added corresponding tests; all relevant test cases pass or skip cleanly.

Let me know if further refactoring or docs are needed.

@aryanchauhan31

Copy link
Copy Markdown
Contributor Author

@sgugger @nateraw Could you please approve the workflows? This PR adds a fast processor for GLPN. Thank you!

@Rocketknight1

Copy link
Copy Markdown
Member

cc @yonigozlan

@yonigozlan yonigozlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @aryanchauhan31 ! Please follow thoroughly the instructions in #36978, and use the command

transformers-cli add-fast-image-processor --model-name model_name

to get started.

You're missing docs, tests, auto configs etc.

from ...image_utils import IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD, PILImageResampling


class GLPNImageProcessorFast(BaseImageProcessorFast):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You are missing the post_process_depth_estimation method. The slow and fast image processors must have the same functionalities!

Comment on lines +20 to +47
import_structure = {
"configuration_glpn": ["GLPNConfig"],
"feature_extraction_glpn": ["GLPNFeatureExtractor"],
"image_processing_glpn": ["GLPNImageProcessor"],
"image_processing_glpn_fast": ["GLPNImageProcessorFast"],
"modeling_glpn": [
"GLPNModel",
"GLPNForDepthEstimation",
"GLPNPreTrainedModel",
],
}

if TYPE_CHECKING:
from .configuration_glpn import *
from .feature_extraction_glpn import *
from .image_processing_glpn import *
from .modeling_glpn import *
from .configuration_glpn import GLPNConfig
from .feature_extraction_glpn import GLPNFeatureExtractor
from .image_processing_glpn import GLPNImageProcessor
from .image_processing_glpn_fast import GLPNImageProcessorFast
from .modeling_glpn import (
GLPNForDepthEstimation,
GLPNModel,
GLPNPreTrainedModel,
)
else:
import os
import sys

_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
sys.modules[__name__] = _LazyModule(__name__, _file, import_structure, module_spec=__spec__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You only need to add this:

    from .image_processing_glpn_fast import *

after

    from .image_processing_glpn import *

No need to modify anything else here.

@aryanchauhan31 aryanchauhan31 Jun 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @yonigozlan

Thanks for the heads-up! I’ll go through the checklist in #36978 and rerun transformers-cli add-fast-image-processor to make sure everything’s in place — docs, tests, auto configs, and all.

Appreciate the nudge — I’ll push the updates soon

@yonigozlan

Copy link
Copy Markdown
Contributor

Closing this PR to give opportunities to others to contribute, as it appears to be stale.

@yonigozlan yonigozlan closed this Aug 1, 2025
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