如何下载拥抱脸情感分析管道脱机使用?,没有互联网,我无法使用拥抱脸情感分析管道。如何下载这条管道?
使用拥抱脸进行情感分析的基本代码是
from transformers import pipeline
classifier = pipeline('sentiment-analysis') #This code will download the pipeline
classifier('We are very happy to show you the Transformers library.')输出是
[{'label': 'POSITIVE', 'score': 0.9997795224189758}]发布于 2021-04-01 15:15:39
使用预培训()方法保存信任、模型权重和词汇表:
classifier.save_pretrained('/some/directory') 并通过指定令牌程序和模型参数来加载它:
from transformers import pipeline
c2 = pipeline(task = 'sentiment-analysis', model='/some/directory', tokenizer='/some/directory')https://stackoverflow.com/questions/66906652
复制相似问题