Closed lizhao-8202 closed 1 month ago
Maybe you could test it by cpu
: device="cpu"
And show me the res.
Maybe you could test it by
cpu
:device="cpu"
And show me the res.
装了rotary_embedding_torch 。然后添加device="cpu" 和不添加这一句,都试了下情况 1、加 device="cpu"
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
model_dir = "D:\\study\\ai\\models\\SenseVoiceSmall"
model = AutoModel(model=model_dir, trust_remote_code=False, device="cuda:0")
res = model.generate(
input=f"{model.model_path}/example/zh.mp3",
cache={},
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech"
use_itn=True,
batch_size=64,
device="cpu",
)
print(f"##########res:{res}")
text = rich_transcription_postprocess(res[0]["text"])
print(text)
日志如下: Notice: ffmpeg is not installed. torchaudio is used to load audio If you want to use ffmpeg backend to load audio, please install it by: sudo apt install ffmpeg # ubuntu
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:35: FutureWarning: torch.cuda.amp.autocast(args...)
is deprecated. Please use torch.amp.autocast('cuda', args...)
instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:262: FutureWarning: torch.cuda.amp.autocast(args...)
is deprecated. Please use torch.amp.autocast('cuda', args...)
instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\funasr\train_utils\load_pretrained_model.py:38: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
src_state = torch.load(path, map_location=map_location)
rtf_avg: 0.282: 100%|██████████| 1/1 [00:01<00:00, 1.59s/it]
##########res:[{'key': 'zh', 'text': '蒟1 작성된11.0.<|en|>.<|en|>致..'}]
蒟1 작성된11.0..致..
2、不加device="cpu"
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
model_dir = "D:\\study\\ai\\models\\SenseVoiceSmall"
model = AutoModel(model=model_dir, trust_remote_code=False, device="cuda:0")
res = model.generate(
input=f"{model.model_path}/example/zh.mp3",
cache={},
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech"
use_itn=True,
batch_size=64,
# device="cpu",
)
print(f"##########res:{res}")
text = rich_transcription_postprocess(res[0]["text"])
print(text)
日志如下: Notice: ffmpeg is not installed. torchaudio is used to load audio If you want to use ffmpeg backend to load audio, please install it by: sudo apt install ffmpeg # ubuntu
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:35: FutureWarning: torch.cuda.amp.autocast(args...)
is deprecated. Please use torch.amp.autocast('cuda', args...)
instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:262: FutureWarning: torch.cuda.amp.autocast(args...)
is deprecated. Please use torch.amp.autocast('cuda', args...)
instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\funasr\train_utils\load_pretrained_model.py:38: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
src_state = torch.load(path, map_location=map_location)
rtf_avg: 0.282: 100%|██████████| 1/1 [00:01<00:00, 1.59s/it]
##########res:[{'key': 'zh', 'text': '1>0<|en|>。<|en|>.<|en|>致<|en|>'}]
1>0。.致
model = AutoModel(model=model_dir, trust_remote_code=False, device="cuda:0")
model = AutoModel(model=model_dir, trust_remote_code=False, device="cpu")
model = AutoModel(model=model_dir, trust_remote_code=False, device="cuda:0")
model = AutoModel(model=model_dir, trust_remote_code=False, device="cpu")
改了。from funasr import AutoModel from funasr.utils.postprocess_utils import rich_transcription_postprocess
model_dir = "D:\study\ai\models\SenseVoiceSmall"
model = AutoModel(model=model_dir, trust_remote_code=False, device="cpu")
res = model.generate( input=f"{model.model_path}/example/zh.mp3", cache={}, language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech" use_itn=True, batch_size=64,
) print(f"##########res:{res}") text = rich_transcription_postprocess(res[0]["text"]) print(text)
日志如下:
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu
# brew install ffmpeg # mac
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:35: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\rotary_embedding_torch\rotary_embedding_torch.py:262: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
@autocast(enabled = False)
D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\funasr\train_utils\load_pretrained_model.py:38: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
src_state = torch.load(path, map_location=map_location)
rtf_avg: 0.279: 100%|██████████| 1/1 [00:01<00:00, 1.58s/it]
##########res:[{'key': 'zh', 'text': '!<町俵 <|en|>.<|ja|>.。'}]
!<町俵..。
Process finished with exit code 0
貌似每执行一次,返回的结果还不一样。
As the notice, maybe you could debug it by set weights_only=True
in https://github.com/modelscope/FunASR/blob/main/funasr/train_utils/load_pretrained_model.py#L38
Make sure you install funasr by source code as the docs: https://github.com/modelscope/FunASR?tab=readme-ov-file#installation
Please make sure torch<=2.3
Please make sure
torch<=2.3
好的。感谢。我试下看
Please make sure
torch<=2.3
换成了2.3.1的貌似正常了,换torch版本过程后会报错,需要重新安装torchaudio,funasr
pip
, source): pip参照readme测试,代码如下
输出结果不对,具体日志如下 Notice: ffmpeg is not installed. torchaudio is used to load audio If you want to use ffmpeg backend to load audio, please install it by: sudo apt install ffmpeg # ubuntu
brew install ffmpeg # mac
If you want use mossformer, lease install rotary_embedding_torch by: pip install -U rotary_embedding_torch If you want use mossformer, lease install rotary_embedding_torch by: pip install -U rotary_embedding_torch If you want use mossformer, lease install rotary_embedding_torch by: pip install -U rotary_embedding_torch If you want use mossformer, lease install rotary_embedding_torch by: pip install -U rotary_embedding_torch Loading remote code failed: model, No module named 'model' D:\AppData\Local\anaconda3\envs\local-sensevoice\Lib\site-packages\funasr\train_utils\load_pretrained_model.py:38: FutureWarning: You are using
torch.load
withweights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_only
will be flipped toTrue
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user viatorch.serialization.add_safe_globals
. We recommend you start settingweights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. src_state = torch.load(path, map_location=map_location) rtf_avg: 0.279: 100%|██████████| 1/1 [00:01<00:00, 1.58s/it] mination缥1001.0000.