Skip to content

how to text-to-3D? #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MathamPollard opened this issue Jun 3, 2025 · 3 comments
Open

how to text-to-3D? #263

MathamPollard opened this issue Jun 3, 2025 · 3 comments

Comments

@MathamPollard
Copy link

No description provided.

@alex-wong123
Copy link

python3 gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0-turbo --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode --enable_flashvdm --enable_t23d

@theoneonlykid69
Copy link

line 709, in load_sub_model
raise ValueError(
ValueError: The component <class 'transformers.models.t5.tokenization_t5._LazyModule.getattr..Placeholder'> of <class 'diffusers.pipelines.pag.pipeline_pag_hunyuandit.HunyuanDiTPAGPipeline'> cannot be loaded as it does not seem to have any of the loading methods defined in {'ModelMixin': ['save_pretrained', 'from_pretrained'], 'SchedulerMixin': ['save_pretrained', 'from_pretrained'], 'DiffusionPipeline': ['save_pretrained', 'from_pretrained'], 'OnnxRuntimeModel': ['save_pretrained', 'from_pretrained'], 'PreTrainedTokenizer': ['save_pretrained', 'from_pretrained'], 'PreTrainedTokenizerFast': ['save_pretrained', 'from_pretrained'], 'PreTrainedModel': ['save_pretrained', 'from_pretrained'], 'FeatureExtractionMixin': ['save_pretrained', 'from_pretrained'], 'ProcessorMixin': ['save_pretrained', 'from_pretrained'], 'ImageProcessingMixin': ['save_pretrained', 'from_pretrained'], 'ORTModule': ['save_pretrained', 'from_pretrained']}.

@theoneonlykid69
Copy link

theoneonlykid69 commented Jun 8, 2025

try
pip install sentencepiece
first,

if that does not work, ""I was able to fix this by adding at file to my main hunyuan3d-2 folder called fix_lazy_loading.py"" copy and past the code below into said file.

fix_lazy_loading.py


# Patch for lazy loading issues
import sys
import importlib

def patch_t5_tokenizer():
    """Force proper loading of T5 tokenizer"""
    try:
        # Force import of T5 tokenizer module
        import transformers.models.t5.tokenization_t5
        
        # Ensure the module is properly loaded
        if hasattr(transformers.models.t5.tokenization_t5, 'T5Tokenizer'):
            print("T5Tokenizer successfully loaded")
            return True
        else:
            print("T5Tokenizer not found in module")
            return False
    except Exception as e:
        print(f"Failed to patch T5 tokenizer: {e}")
        return False

def patch_transformers():
    """Apply patches to fix lazy loading"""
    # Import transformers first
    import transformers
    
    # Force load tokenizer modules
    from transformers import T5Tokenizer, T5TokenizerFast
    
    # Monkey patch the lazy module if needed
    import transformers.models.t5.tokenization_t5 as t5_tokenizer_module
    
    # Ensure classes are properly exposed
    if not hasattr(t5_tokenizer_module, 'T5Tokenizer'):
        t5_tokenizer_module.T5Tokenizer = T5Tokenizer
    
    print("Transformers patching complete")

if __name__ == "__main__":
    patch_transformers()
    patch_t5_tokenizer()

add this file to the same folder with your gradio_app.py file.

then add


import fix_lazy_loading
fix_lazy_loading.patch_transformers()

this line below "import logger" in the gradio_app.py

now you can run

python gradio_app.py --enable_t23d

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

No branches or pull requests

3 participants