open-mmlab / Amphion

Amphion (/æmˈfaɪən/) is a toolkit for Audio, Music, and Speech Generation. Its purpose is to support reproducible research and help junior researchers and engineers get started in the field of audio, music, and speech generation research and development.
https://openhlt.github.io/amphion/
MIT License
4.45k stars 379 forks source link

[Help]: Soft link not work #133

Closed xiangmy21 closed 7 months ago

xiangmy21 commented 7 months ago

Problem Overview

I follow the https://huggingface.co/amphion/naturalspeech2_libritts and https://github.com/open-mmlab/Amphion/tree/main/egs/tts/NaturalSpeech2 to use NaturalSpeech2 for inference, but the soft link created by command ln -s ../../../naturalspeech2_libritts ckpts/tts/ seems not work. It still report FileNotFoundError: [Errno 2] No such file or directory: '~/amphion/ckpts/tts/naturalspeech2_libritts/checkpoint/epoch-0089_step-0512912_loss-6.367693/pytorch_model.bin'

Screenshots

image

I'm sure /home/srt15/naturalspeech2/checkpoint/epoch-0089_step-0512912_loss-6.367693/pytorch_model.bin is existent.

HarryHe11 commented 7 months ago

Could you please share the details of the files located in the '~/amphion/ckpts/tts/naturalspeech2_libritts/checkpoint/epoch-0089_step-0512912_loss-6.367693' folder?

xiangmy21 commented 7 months ago

There is only a soft link in /home/srt15/amphion/ckpts/tts/,as the first capture shows. now I deleted the soft link, and move the /home/srt15/naturalspeech2_libritts/ folder directly into /home/srt15/amphion/ckpts/tts/naturalspeech2_libritts/,and it works. So I wonder why the soft link doesn't work.

image
HarryHe11 commented 7 months ago

In this situation, it seems to be related to the way Accelerate handles model loading. To potentially address this issue, you might consider introducing a piece of code before the model loading process. This additional step involves obtaining the actual path of the symlinked file. Here's a revised version of the code snippet:

path = [YOUR-SOFT-LINK-PATH]
# Resolve the actual path of the symlinked file
realpath = path if not os.path.islink(path) else os.readlink(path) 
# Load the model using the resolved path
load_model(realpath)
xiangmy21 commented 7 months ago

Oh, God! Sorry, it's my problem. I add the soft link again and it works:

image

When using relative path to add soft link, the path should be based on the link path. Maybe I used the wrong relative path at first. Sorry for disturbing, and thanks for your help!