★★★ 本文源自AI Studio社区精品项目,【点击此处】查看更多精品内容 >>>


基于文心大模型的剧本杀海报生成器(武侠篇)

一、技术路线

  作为一个娱乐项目,剧本杀在近年来很快流行起来,本项目依托文心大模型,支持低成本剧本杀产品落地、宣发阶段业务需求,低成本快速产图,一键式生成剧本杀海报,根据剧本内容一键提取剧本杀摘要/关键词+根据出现最多的主题词生成图片,完成文配图,生成简易的海报。

  本次主要使用文心大模型结合paddlenlp,如果文章在1000字以内可以使用文心大模型的摘要生成(我觉得这个是可以升级的点,比如支持更多的字数),首先使用PaddleNLP对整个小说进行摘要提取,其次根据摘要提取的关键词生成海报。

二、代码实现

  首先安装wenxin_api,接着使用PaddleNLP的Taskflow功能对文章提取摘要,最后再使用文心大模型的AI作图,生成海报图。

! pip install wenxin_apiimport wenxin_api # 可以通过"pip install wenxin-api"命令安装
from wenxin_api.tasks.text_to_image import TextToImage
from paddlenlp import Taskflow
summarizer = Taskflow("text_summarization")wenxin_api.ak = ""
wenxin_api.sk = ""test_text = 'duoqingjiankewuqingjian_gulong.txt'
with open(test_text,'r') as f:text = f.read()title = summarizer(text)
print(f'Title: {title[0]}')input_dict = {"text": title[0] + "超高清,超细节,唯美,插画,壁纸,背影","style": "古风", #解锁更多风格后,非必选参数"resolution":"1024*1536" , #也可设置为 1024*1536、1536*1024"num": "4",    #功能解锁后,可设置的范围为[1,2,3,4,5,6]
}
rst = TextToImage.create(**input_dict)
print(rst)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: wenxin_api in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (0.1.7)
Requirement already satisfied: tqdm in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from wenxin_api) (4.64.1)
Requirement already satisfied: requests>=2.20 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from wenxin_api) (2.24.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20->wenxin_api) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20->wenxin_api) (1.25.11)
Requirement already satisfied: idna<3,>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20->wenxin_api) (2.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20->wenxin_api) (3.0.4)[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m A new release of pip available: [0m[31;49m22.1.2[0m[39;49m -> [0m[32;49m22.3.1[0m
[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m To update, run: [0m[32;49mpip install --upgrade pip[0m[2023-01-06 18:57:54,805] [    INFO] - Downloading tokenizer_config.json from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/tokenizer_config.json
100%|██████████| 2.00/2.00 [00:00<00:00, 1.37kB/s]We use pattern recognition to recognize the Tokenizer class.[2023-01-06 18:57:54,896] [    INFO] - We are using <class 'paddlenlp.transformers.pegasus.tokenizer.PegasusChineseTokenizer'> to load 'IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese'.
[2023-01-06 18:57:54,899] [    INFO] - Downloading https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/vocab.txt and saved to /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese
[2023-01-06 18:57:54,902] [    INFO] - Downloading vocab.txt from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/vocab.txt
100%|██████████| 365k/365k [00:00<00:00, 1.40MB/s]
[2023-01-06 18:57:55,319] [    INFO] - Downloading https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/added_tokens.json and saved to /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese
[2023-01-06 18:57:55,321] [    INFO] - Downloading added_tokens.json from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/added_tokens.json
100%|██████████| 2.00/2.00 [00:00<00:00, 1.46kB/s]
[2023-01-06 18:57:55,408] [    INFO] - Downloading https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/special_tokens_map.json and saved to /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese
[2023-01-06 18:57:55,410] [    INFO] - Downloading special_tokens_map.json from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/special_tokens_map.json
100%|██████████| 66.0/66.0 [00:00<00:00, 41.5kB/s]
[2023-01-06 18:57:55,529] [    INFO] - Already cached /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/tokenizer_config.json
[2023-01-06 18:57:55,596] [    INFO] - Downloading model_config.json from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/model_config.json
100%|██████████| 732/732 [00:00<00:00, 480kB/s]
[2023-01-06 18:57:55,714] [    INFO] - We are using <class 'paddlenlp.transformers.pegasus.modeling.PegasusForConditionalGeneration'> to load 'IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese'.
[2023-01-06 18:57:55,716] [    INFO] - Downloading https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/model_state.pdparams and saved to /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese
[2023-01-06 18:57:55,718] [    INFO] - Downloading model_state.pdparams from https://bj.bcebos.com/paddlenlp/models/community/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/model_state.pdparams
100%|██████████| 1.26G/1.26G [01:47<00:00, 12.7MB/s]
[2023-01-06 18:59:42,848] [    INFO] - Already cached /home/aistudio/.paddlenlp/models/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese/model_config.json
Building prefix dict from the default dictionary ...
Dumping model to file cache /tmp/jieba.cache
Loading model cost 0.758 seconds.
Prefix dict has been built successfully.Title: 李寻欢的寂寞
2023-01-06 19:01:25,149 - model is painting now!, taskId: 12624128, waiting: 2m
2023-01-06 19:01:45,663 - model is painting now!, taskId: 12624128, waiting: 50s
2023-01-06 19:02:06,096 - model is painting now!, taskId: 12624128, waiting: 50s
{'imgUrls': ['https://wenxin.baidu.com/younger/file/ERNIE-ViLG/ec986708ad955c6f42fadf9681a889f15q', 'https://wenxin.baidu.com/younger/file/ERNIE-ViLG/ec986708ad955c6f42fadf9681a889f130', 'https://wenxin.baidu.com/younger/file/ERNIE-ViLG/ec986708ad955c6f42fadf9681a889f1ex', 'https://wenxin.baidu.com/younger/file/ERNIE-ViLG/ec986708ad955c6f42fadf9681a889f1i4']}

基于文心大模型的剧本杀海报生成器(武侠篇)相关推荐

  1. 情人节走进文心,走进她的心,基于文心大模型套件ERNIEKit实现文本匹配算法

    #★★★本文源自AlStudio社区精品项目, [点击此处]查看更多精品内容 >>> (https://aistudio.baidu.com/aistudio/proiectover ...

  2. 【新春特辑】基于文心大模型的新年春联生成器

    ★★★ 本文源自AI Studio社区精品项目,[点击此处]查看更多精品内容 >>> [新春特辑]基于文心大模型的新年春联生成器 一.技术路线 首先,使用文心大模型的对联功能,通过上 ...

  3. 2.基于文心大模型套件ERNIEKit实现文本匹配算法,模块化方便应用落地

    文心大模型,产业级知识增强大模型介绍 官网:https://wenxin.baidu.com/ 项目链接见文末 文心大模型开发套件ERNIEKit,面向NLP工程师,提供全流程大模型开发与部署工具集, ...

  4. 数字人度晓晓AI画作卖出17万元,飞桨文心大模型推动AIGC时代到来

    本文已在飞桨公众号发布,查看请戳链接: 数字人度晓晓AI画作卖出17万元,飞桨文心大模型推动AIGC时代到来 一年一度的国内顶尖艺术院校的毕业展,成为最值得期待的中国艺术新兴力量们的展示舞台.在今年6 ...

  5. 首届“兴智杯”产业赛收官,文心大模型助推产业创新

    由工业和信息化部.科学技术部.深圳市人民政府共同主办,中国信通院等单位承办的首届"兴智杯"全国人工智能创新应用大赛圆满收官.本次大赛受到国家部委.政府机构.科技企业.高校师生等社会 ...

  6. 开疆作剑,开荒为犁:2022春天,文心大模型走进产业的百花深处

    在联合国总部的花园里,矗立着一尊青铜雕塑,名为"Let Us Beat Swords into Plowshares",一个人手拿锤子,正在将剑改铸为犁--"铸剑为犁&q ...

  7. 百度文心大模型开发者斩获CCF BDCI大赛唯一『最佳算法能力奖』

    ‍2023年2月24日至25日,中国计算机学会(CCF)主办.苏州市吴江区人民政府支持,苏州市吴江区工信局.吴江区东太湖度假区管理办公室.苏州市吴江区科技局.CCF大数据专家委员会及其他专业委员会等多 ...

  8. 文心大模型api使用

    文心大模型api使用 首先,我们要获取硅谷社区的连个key 复制两个api备用 获取Access Token 获取access_token示例代码 之后就会输出 作文创作 作文创作:作文创作接口基于文 ...

  9. 文心大模型之我爱我家

    文心大模型之我爱我家 一.项目简介 要达成的目标是:发挥你的创造力,使用文心大模型设计自己温馨的家园 主要思路是:先得到装修设计创意或方案,然后生成装修设计图片,最后转成视频 通过 文心大模型得到厨房 ...

最新文章

  1. 如何制定恰当的信息安全策略
  2. 突破Windows下select64的限制
  3. 字典删除多个键值对方法_Life is short,you need Python——Python序列(元组、字典、集合)...
  4. X-Magic Pair gcd,剪枝(1600)
  5. 【转】在Ubuntu中运行Exe程序
  6. Rancher2.0中邮件通知的设置
  7. UWP 中的 LaunchUriAsync,使用默认浏览器或其他应用打开链接
  8. springMVC-配置Bean
  9. bzoj 1015 并查集
  10. 二、操作系统——用信号量机制实现进程互斥、同步、前驱关系(详解)
  11. mysql主从代替技术_mysql主从复制及失败切换
  12. 烟台市与拼多多达成战略合作 启动烟台优品线上云购节活动
  13. 台积电5nm来了!谁会是第一个吃螃蟹的人
  14. python中格式化_python的format格式化
  15. RabbitMQ消息队列-VirtualHost与权限管理
  16. c语言troubc int类型占几个字节,程序设计基础(C)第06讲例程
  17. 2019中国软件百强榜:华为、阿里、百度、腾讯位列前四
  18. Ubuntu中扩大虚拟机硬盘容量
  19. 拷贝控制示例——Message和Folder
  20. 计算机网络技术文档心得,计算机网络技术学习心得体会.docx

热门文章

  1. JDK8新特性-Lambda
  2. 用生产者消费者模式爬取斗图吧,一次性收获超多表情包【python爬虫入门进阶】(11)
  3. 愿天下有情人都是失散多年的兄妹 (25分)
  4. 小程序怎么弄?小程序开发多少钱?
  5. 软件自动升级解决方案(一)
  6. vue实现图片自定义尺寸裁切并上传
  7. 深圳小汽车车牌竞拍价格预测
  8. 华为line服务器无响应,line注册链接不到服务器
  9. 一文读懂对抗学习!5千字精炼提干
  10. PX4中的二阶巴特沃斯低通滤波