代码拉取完成,页面将自动刷新
同步操作将从 codemayq/openmind_design 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from pipeline import pipeline
from util import logger, print_func_and_docs
@print_func_and_docs
def chat_with_only_task():
"""只输入task为chat,有默认模型"""
chat_pipeline = pipeline("chat")
resp = chat_pipeline(messages=
[
{
"role": "user",
"content" : "hi"
}
]
)
@print_func_and_docs
def chat_with_only_model():
"""只输入模型"""
chat_pipeline = pipeline(model="Baichuan/Baichuan2_7b_chat_pt")
resp = chat_pipeline(messages=
[
{
"role": "user",
"content" : "hi"
}
]
)
@print_func_and_docs
def chat_with_task_and_model():
"""输入task和模型"""
chat_pipeline = pipeline("chat", model="Baichuan/Baichuan2_7b_chat_pt")
resp = chat_pipeline(messages=
[
{
"role": "user",
"content": "hi"
}
]
)
@print_func_and_docs
def chat_with_ms_framework():
"""ms框架"""
chat_pipeline = pipeline("chat", model="Baichuan/Baichuan2_7b_chat_pt",framework="ms")
resp = chat_pipeline(messages=
[
{
"role": "user",
"content": "hi"
}
]
)
@print_func_and_docs
def text2image_with_only_task():
"""只输入task为text2image,但是没有默认模型"""
try:
text2image_pipeline = pipeline("text2image")
resp = text2image_pipeline(prompt = "beautiful flower, oil painting style")
except Exception as e:
logger.error(e)
@print_func_and_docs
def text2image_with_extra_param():
"""输入task和model, 额外输入width, height"""
text2image_pipeline = pipeline("text2image", model="PyTorch-NPU/stable-diffusion-2-1")
resp = text2image_pipeline(prompt = "beautiful flower, oil painting style", width=2000, height=1000)
@print_func_and_docs
def text2image_with_silicon():
"""输入task和model, 开启silicon 加速"""
text2image_pipeline = pipeline("text2image", model="PyTorch-NPU/stable-diffusion-2-1", use_silicon=True)
resp = text2image_pipeline(prompt = "beautiful flower, oil painting style", width=2000, height=1000)
@print_func_and_docs
def text2image_with_ms():
"""输入task和model, 使用ms framework"""
try:
text2image_pipeline = pipeline("text2image", model="PyTorch-NPU/stable-diffusion-2-1", framework="ms")
resp = text2image_pipeline(prompt = "beautiful flower, oil painting style", width=2000, height=1000)
except Exception as e:
logger.error(e)
@print_func_and_docs
def common_pt_only_task():
"""未专门注册过的任务, 使用pt framework, 现在版本的pipeline可以都放在这里"""
text2image_pipeline = pipeline("text_classification")
resp = text2image_pipeline(text="候选文本")
@print_func_and_docs
def common_pt_only_model():
"""未专门注册过的任务, 使用pt framework, 现在版本的pipeline可以都放在这里"""
text2image_pipeline = pipeline(model="PyTorch-NPU/resnet_50", framework="pt")
resp = text2image_pipeline(pic= "http://123.png")
@print_func_and_docs
def common_ms():
"""未专门注册过的任务, 使用ms framework, 现在版本的pipeline可以都放在这里"""
text2image_pipeline = pipeline(model="PyTorch-NPU/distilbert_base_uncased_finetuned_sst_2_english", framework="ms")
resp = text2image_pipeline(text="Today is a good day")
def output_support_report():
"""输出当前openmind完整任务和支持模型,依赖列表"""
pass
def output_docker_file():
"""指定模型,framework,生成容器镜像配置文件"""
pass
if __name__ == '__main__':
# chat_with_only_task()
# chat_with_only_model()
# chat_with_task_and_model()
# chat_with_ms_framework()
# text2image_with_only_task()
# text2image_with_extra_param()
# text2image_with_silicon()
# text2image_with_ms()
common_pt_only_task()
# common_pt_only_model()
# common_ms()
# output_support_report()
# output_docker_file()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。