Restore Hugging Face Integration and Implement from_pretrained() Support#339
Open
Muhammad-Ikhwan-Fathulloh wants to merge 1 commit into
Open
Restore Hugging Face Integration and Implement from_pretrained() Support#339Muhammad-Ikhwan-Fathulloh wants to merge 1 commit into
from_pretrained() Support#339Muhammad-Ikhwan-Fathulloh wants to merge 1 commit into
Conversation
…d, and improve backward compatibility This commit: 1. Restores missing moondream.hf module structure 2. Adds from_pretrained() class method to HfMoondream that uses huggingface_hub to download models 3. Fixes generate() method to properly call _generate_answer with correct parameters 4. Adds backward-compatible caption() and encode_image() methods that accept list of images 5. Adds missing huggingface_hub dependency 6. Registers HfConfig and HfMoondream with HF Auto classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Closes #338
Summary
This PR restores missing Hugging Face integration components and fixes several regressions that prevented Moondream from working with standard Hugging Face workflows.
Changes Included
Restored Hugging Face package structure
Added missing files:
moondream/hf/util.pymoondream/hf/moondream.pymoondream/hf/__init__.pyRestored:
moondream/__init__.pyThese files provide the Hugging Face compatibility layer and restore import paths used by existing examples and downstream projects.
Fixed
HfMoondream.generate()Updated the implementation to correctly forward arguments to
_generate_answer(), including:posThis resolves generation failures caused by missing parameters.
Implemented
from_pretrained()Added a Hugging Face-compatible loading interface:
The implementation:
huggingface_hub.snapshot_download.safetensorsand.ptcheckpointsload_weights_into_modelRestored backward compatibility
Updated APIs to support previous usage patterns:
caption()encode_image()This helps prevent breakages in existing integrations and user code.
Dependencies
Added:
to ensure Hub downloads are available for
from_pretrained().Validation
Verified the following workflows:
Direct loading
Transformers AutoModel loading
Legacy API compatibility
Impact
This PR restores:
from_pretrained()supportand resolves the regressions reported in #338.