Hunyuan3D-2 icon indicating copy to clipboard operation
Hunyuan3D-2 copied to clipboard

FileNotFoundError: Model path tencent/Hunyuan3D-2 not found and we could not find it at huggingface

Open alexisrolland opened this issue 10 months ago • 14 comments

Hello and thank you for open sourcing these models! I've been trying to run the api_server.py as well as ComfyUI nodes from this repo. In both cases I keep having the same error with the texture generation module.

hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr | Traceback (most recent call last):
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |   File "/usr/app/Hunyuan3D-2/api_server.py", line 272, in <module>
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |     worker = ModelWorker(model_path=args.model_path, device=args.device)
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |   File "/usr/app/Hunyuan3D-2/api_server.py", line 142, in __init__
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |     self.pipeline_tex = Hunyuan3DPaintPipeline.from_pretrained(model_path)
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |   File "/usr/app/Hunyuan3D-2/hy3dgen/texgen/pipelines.py", line 86, in from_pretrained
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr |     raise FileNotFoundError(f"Model path {original_model_path} not found and we could not find it at huggingface")
hunyuan3d  | 2025-02-01 11:44:32 | ERROR | stderr | FileNotFoundError: Model path tencent/Hunyuan3D-2 not found and we could not find it at huggingface

My model files seem to be properly downloaded, I have this:

Image

I looked into your code and I noticed the function Hunyuan3DPaintPipeline.from_pretrained always raises a FileNotFoundError line 86. Is it normal? https://github.com/Tencent/Hunyuan3D-2/blob/main/hy3dgen/texgen/pipelines.py#L86

class Hunyuan3DPaintPipeline:
    @classmethod
    def from_pretrained(cls, model_path):
        original_model_path = model_path
        if not os.path.exists(model_path):
            # try local path
            base_dir = os.environ.get('HY3DGEN_MODELS', '~/.cache/hy3dgen')
            model_path = os.path.expanduser(os.path.join(base_dir, model_path))

            delight_model_path = os.path.join(model_path, 'hunyuan3d-delight-v2-0')
            multiview_model_path = os.path.join(model_path, 'hunyuan3d-paint-v2-0')

            if not os.path.exists(delight_model_path) or not os.path.exists(multiview_model_path):
                try:
                    import huggingface_hub
                    # download from huggingface
                    model_path = huggingface_hub.snapshot_download(repo_id=original_model_path)
                    delight_model_path = os.path.join(model_path, 'hunyuan3d-delight-v2-0')
                    multiview_model_path = os.path.join(model_path, 'hunyuan3d-paint-v2-0')
                    return cls(Hunyuan3DTexGenConfig(delight_model_path, multiview_model_path))
                except ImportError:
                    logger.warning(
                        "You need to install HuggingFace Hub to load models from the hub."
                    )
                    raise RuntimeError(f"Model path {model_path} not found")
            else:
                return cls(Hunyuan3DTexGenConfig(delight_model_path, multiview_model_path))

        raise FileNotFoundError(f"Model path {original_model_path} not found and we could not find it at huggingface")

How can I solve this issue please?

alexisrolland avatar Feb 01 '25 12:02 alexisrolland

It probably occur some exception in try block, which is not an import error. Could you try to comment out the catch block to see what error occurs?

Zeqiang-Lai avatar Feb 01 '25 14:02 Zeqiang-Lai

非常有意思的代码逻辑 if not os.path.exists(model_path): …… raise FileNotFoundError(f"Model path {original_model_path} not found and we could not find it at huggingface")

如果路径存在,那么抛异常😂

buaa-csc avatar Mar 21 '25 02:03 buaa-csc

it should be written as

try:
    import huggingface_hub
except ImportError:
    logger.warning(
        "You need to install HuggingFace Hub to load models from the hub."
    )
    raise RuntimeError(f"Model path {model_path} not found")
else:
    # download from huggingface
    model_path = huggingface_hub.snapshot_download(repo_id=original_model_path)
    delight_model_path = os.path.join(model_path, 'hunyuan3d-delight-v2-0')
    multiview_model_path = os.path.join(model_path, 'hunyuan3d-paint-v2-0')
    return cls(Hunyuan3DTexGenConfig(delight_model_path, multiview_model_path))

GZY219 avatar Mar 25 '25 11:03 GZY219

same issue

jonahhache avatar Mar 28 '25 06:03 jonahhache

same

Ulysses-Gaia avatar Apr 20 '25 14:04 Ulysses-Gaia

same issue

Lefox-DeMod avatar Apr 24 '25 14:04 Lefox-DeMod

same issue

harpreetsahota204 avatar Apr 24 '25 19:04 harpreetsahota204

Same issue

tcharbonneauAriann avatar May 02 '25 20:05 tcharbonneauAriann

I too am experiencing this issue, however it's with the API. I've downloaded the model, place it in ./tencent/Hunyuan3d-2. I've even tried to update the script with a full path.

Image

donaldparker avatar May 07 '25 17:05 donaldparker

facing the same issue.

karancode avatar Aug 04 '25 14:08 karancode

same

remingthon avatar Aug 19 '25 17:08 remingthon

I was having the same issue, and it was because I was using an outdated fork. The problem appears to have been fixed in https://github.com/Tencent-Hunyuan/Hunyuan3D-2/commit/8efbe53a7e09bffb3efc71045147afd0bbd149d4

centuryglass avatar Oct 14 '25 18:10 centuryglass

no, it's not solved. That commit is in another file (texgen instead of shapegen). If you pass a --model_path to api_server.py that you haven't downloaded already, it won't be able to resolve because the subfolder in api_server.py doesn't exist: subfolder='hunyuan3d-dit-v2-mini-turbo'

https://huggingface.co/tencent/Hunyuan3D-2/tree/main

there's currently no way to pass a subfolder to api_server.py via args


if you can modify the api_server.py

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--host", type=str, default="0.0.0.0")
    parser.add_argument("--port", type=int, default=8081)
    parser.add_argument("--model_path", type=str, default='tencent/Hunyuan3D-2mini')
    parser.add_argument("--tex_model_path", type=str, default='tencent/Hunyuan3D-2')
    parser.add_argument('--subfolder', type=str, default="hunyuan3d-dit-v2-mini-turbo")
    parser.add_argument("--device", type=str, default="cuda")
    parser.add_argument("--limit-model-concurrency", type=int, default=5)
    parser.add_argument('--enable_tex', action='store_true')
    args = parser.parse_args()
    logger.info(f"args: {args}")

    model_semaphore = asyncio.Semaphore(args.limit_model_concurrency)

    worker = ModelWorker(model_path=args.model_path, device=args.device, enable_tex=args.enable_tex,
                         tex_model_path=args.tex_model_path, subfolder=args.subfolder)
    uvicorn.run(app, host=args.host, port=args.port, log_level="info")

and then call

    python3 api_server.py \
        --host 0.0.0.0 \
        --port 8080 \
        --enable_tex \
        --model_path tencent/Hunyuan3D-2 \
        --subfolder hunyuan3d-dit-v2-0-turbo \
        --tex_model_path tencent/Hunyuan3D-2

as you can see I changed subfolder from hunyuan3d-dit-v2-mini-turbo to hunyuan3d-dit-v2-0-turbo

PascalSalesch avatar Oct 29 '25 15:10 PascalSalesch

same issue

hireshBrem avatar Nov 09 '25 03:11 hireshBrem