Skip to content

Hut101 19 jhwisdom#577

Merged
rwood-97 merged 5 commits intomaps-as-data:mainfrom
jhwisdom:hut101-19-jhwisdom
Mar 25, 2026
Merged

Hut101 19 jhwisdom#577
rwood-97 merged 5 commits intomaps-as-data:mainfrom
jhwisdom:hut101-19-jhwisdom

Conversation

@jhwisdom
Copy link
Copy Markdown

@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?

Copy link
Copy Markdown
Collaborator

@rwood-97 rwood-97 left a comment

Choose a reason for hiding this comment

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

Hi Jihye,

I've added a few small comments.

Could you also have a go at updating the docs, this is the file you'd need to edit: https://github.com/maps-as-data/MapReader/blob/main/docs/source/using-mapreader/step-by-step-guide/4-classify/train.rst

The unit tests are failing at the moment but this isn't your fault - it is a dependency issue I think so I will try fix these in a separate branch.
The only one you need to fix is the check changelog test, this basically checks you've updated the changelog CHANGELOG.md as part of your PR. To fix it you just need to update the CHANGELOG.md file with your changes.

Thanks for doing this :)

@rwood-97
Copy link
Copy Markdown
Collaborator

Hi Jihye,

I've just fixed the issue with the tests failing. Can you run the following commands to incorportate these changes into your PR:

git checkout main
git pull
git checkout jhwisdom:hut101-19-jhwisdom
git rebase main
git push -f

@jhwisdom
Copy link
Copy Markdown
Author

Hi Rosie,
I checked your comments right now. Thank you for the fixes.
Yes, I can try to run the commands.

@rwood-97 rwood-97 self-requested a review March 17, 2026 11:38
Copy link
Copy Markdown
Collaborator

@rwood-97 rwood-97 left a comment

Choose a reason for hiding this comment

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

Great, thanks so much for doing this :) Please go ahead and merge this now

@rwood-97 rwood-97 merged commit 08fceec into maps-as-data:main Mar 25, 2026
3 checks passed
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.

2 participants