Skip to content

Hut101 19 jhwisdom#577

Open
jhwisdom wants to merge 2 commits intomaps-as-data:mainfrom
jhwisdom:hut101-19-jhwisdom
Open

Hut101 19 jhwisdom#577
jhwisdom wants to merge 2 commits intomaps-as-data:mainfrom
jhwisdom:hut101-19-jhwisdom

Conversation

@jhwisdom
Copy link

@jhwisdom jhwisdom commented Feb 4, 2026

Summary

This pull request adds support for Hugging Face models within the ClassifierContainer. Previously, users had to manually load Hugging Face models and feature extractors before passing them to the container. Now, by simply passing a Hugging Face repository path and setting the huggingface=True flag, the container handles the initialization automatically. (It is a part of the participation in the hut101 opportunities)

Fixes #192

Describe your changes

  • Updated ClassifierContainer.__init__: Added a huggingface boolean flag (defaulting to False).
  • Integrated transformers library:
    • Implemented conditional loading of models using AutoModelForImageClassification.from_pretrained.
    • Added ignore_mismatched_sizes=True to allow easy fine-tuning on custom labels.
  • Compatibility:
    • Set self.is_inception = False for HF models to bypass legacy Inception-specific logic while maintaining the existing _get_logits workflow.
    • Used getattr to dynamically set self.input_size from the processor's configuration, ensuring compatibility across different HF models.

Checklist before assigning a reviewer (update as needed)

  • Self-review code
  • Ensure submission passes current tests
  • Add tests (Tested manually with HF models)
  • Update relevant docs
  • Update changelog

Reviewer checklist

Please add anything you want reviewers to specifically focus/comment on.

  • Everything looks ok?

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.

Set up a function/method which allows us to load/save HF models easily in the mapreader pipeline.

1 participant