Text2Poster-ICASSP-22

Text2Poster-ICASSP-22

基于AI的智能海报布局生成系统

Text2Poster-ICASSP-22是一个基于人工智能的海报生成系统,结合了图像检索和文本布局技术。该项目能够根据输入文本自动选择合适的背景图片并进行智能排版,支持多语言输入。系统提供API接口,便于快速集成和使用。Text2Poster适用于各种需要快速生成高质量海报的场景,如活动宣传、营销推广等。

Text2Poster图文布局海报生成背景图像检索AI应用Github开源项目

Text2Poster-ICASSP-22

The inference code of the ICASSP-2022 paper "Text2Poster: Laying Out Stylized Texts on Retrieved Images".

framework

Paper Link: https://arxiv.org/abs/2301.02363

Star History

Star History Chart

If you like this project, please give it a star! It would be a great encouragement for me and help me to continue improving it.

Quick Start from API

Just run the following code to quick start:

import time, json, requests timestamp = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) input_text_elements = { "sentences": [ ["CHILDREN'S DAY", 90], # [text, font_size] ["Children are The Future of Nation", 50] # [text, font_size] ], "background_query": "Children's Day!" # sentence used to retrieve background images. } input_text_elements = json.dumps(input_text_elements) api_url = "http://bl.mmd.ac.cn:8889/text2poster" response = requests.get(api_url, params = {"input_text_elements": input_text_elements}) if response.status_code == 200: f = open("poster-{}.jpg".format(timestamp), "wb") f.write(response.content) f.close() print("Save poster to:", "poster-{}.jpg".format(timestamp)) else: print(response.text)

News

  • [2023.1.24] Update "http://1.13.255.9" to "http://bl.mmd.ac.cn".
  • [2023.1.17] We provide an API for Text2Poster, you can quickly start our Text2Poster without any resource download.
  • [2023.1.16] We add a machine translation API to translate all the input texts into Chinese. So that the BriVL model could deal with all languages. Now you can try to retrieve background images in any language!!
  • [2023.1.15] We provide an unsplash image download script in ./background_retriever/unsplash_image_downloader.py, you can use this script to get those background image files based on the retrieved image urls.
  • [2023.1.14] We provide our image retrieval source code and data in ./background_retriever for the convenience of people who are not in mainland China to use our Text2Poster. You can retrieve the background image locally, which requires about 3GB of GPU memory.
  • [2023.01.10] We update the background image retrieval website to http://1.13.255.9:8889. The original website buling.wudaoai.cn has been retired in 2023.01.09.

Generated Posters:

<img src="./poster-20230117000304.jpg" alt="poster" height="260"/> <img src="./poster-20230117002210.jpg" alt="poster" height="260"/>

More Examples

  • input text elements 1

55, 40 and 30 are the font size.

{ "sentences": [ ["冬日初雪舞会", 55], ["雪花飞舞,像音乐和歌声围绕", 40], ["与朋友相聚,享受欢乐时光,我们不见不散", 30] ], "background_query": "冬日初雪舞会" }
  • output posters

<img src="./example/outputs_1/0/poster.jpg" alt="poster" height="250" /> <img src="./example/outputs_1/1/poster.jpg" alt="poster" height="250" />

  • input text elements 2

80 and 55 are the font size.

{ "sentences": [ ["ICASSP 2022", 80], ["May 22 - 27, 2022, Singapore", 55] ], "background_query": "Singapore" }

output posters

<img src="./example/outputs_2/1/poster.jpg" alt="poster" height="250" /> <img src="./example/outputs_2/2/poster.jpg" alt="poster" height="250" />

  • input text elements 3

90 and 50 are the font size.

{ "sentences": [ ["桜が咲く", 90], ["出会いは素晴らしい春に", 50] ], "background_query": "春の美しい桜" }

output posters

<img src="./example/outputs_3/3/poster.jpg" alt="poster" height="260" /> <img src="./example/outputs_3/1/poster.jpg" alt="poster" height="260" />

Start from Source Code

Install

We recommend you use anaconda to run our Text2Poster. Run the following command to install the dependent libraries:

bash install_package.sh

you also can install the dependent libraries manually:

# using the tsinghua mirror to speed up the install. conda install pytorch=1.10.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda install torchvision=0.11.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ pip install opencv_contrib_python pip install transformers==3.2.0 pip install argparse pip install freetype-py pip install requests pip install jsonlines pip install tqdm pip install pyyaml pip install easydict pip install timm

Download

We provide the following resource to start Text2Poster:

  • Weights of layout refine model: ./checkpoint/0.20484_Cascading_128_uniform_big.pth;
  • Weights of layout distribution prediction model: ./checkpoint/27.80619_distribCNN_BigPosition_epoch_76_scale_20.pth;

[Not required] Although we provide an API for background image retrieval, if you want to retrieve background images from the source code, you need to download the following resources:

  • Weights of text encoder of BriVL: brivl-textencoder-weights.pth -> ./background_retriever/weights/;
  • Unsplash images features (extracted by BriVL): wenlan_unsplash_feats.npy -> ./background_retriever/background_feats/;
  • URL of background images: ./background_retriever/background_feats/unsplash_image_url.jsonl.

Running

We provide two example, Run the following command to run our Text2Poster:

bash run.sh

Some parameters:

  • input_text_file: The input text elements, it contains: 1). sentences (phase) and their font size, 2). query used to retrieve background images.
  • output_folder: The folder to save the output posters and some process figures.
  • background_folder: The folder to save local background images, If images are not saved locally, they will be downloaded from remote.
  • top_n: Arrange the text elements on the top N retrieved images.
  • save_process: Save the process figure (etc. saliency map) or not.

We also provide the following examples:

  • background image retrieval (from API)
python background_retrieval.py
  • background image retrieval (from source code)
cd background_retriever python main.py
  • Layout distribution prediction
python layout_distribution_predict.py
  • Layout refinement
python layout_refine.py
  • Download images from Unsplash
python ./background_retriever/unsplash_image_downloader.py

Some Output During Process

we also output some intermediate processing files in ./example/outputs:

<img src="./bk_image_folder/-SdD0KbD7N0.png" alt="-SdD0KbD7N0" height="250" /> <img src="./example/outputs_1/0/saliency_map_with-smooth.jpg" alt="saliency_map_with-smooth" height="250" />

  • Right image: The original background image.
  • Left image: Saliency map (blue) with smooth region map (red).

<img src="./example/outputs_1/0/layout_distribution.jpg" alt="layout_distribution" height="250" /> <img src="./example/outputs_1/0/saliency_map_with-layout-distribution.jpg" alt="saliency_map_with-smooth" height="250" />

  • Right image: The prediction of layout distribution map.
  • Left image: Saliency map (blue) with predicted layout distribution map (red).

<img src="./example/outputs_1/0/initial_layout.jpg" alt="initial_layout" height="250" /> <img src="./example/outputs_1/0/refined_layout.jpg" alt="refined_layout" height="250" />

  • Right image: Initial layout map.
  • Left image: Refined layout map.

Blue region: The saliency map;

Green region: The predicted layout distribution map;

Red region: the predicted layout map.

Tips

Something about our background image retrieval

Requirements

python==3.7
pytorch=1.10.0
torchvision=0.11.0
transformers==3.2.0
freetype-py
opencv_contrib_python
requests
jsonlines
tqdm
argparse
pyyaml
easydict
timm

Citation

If you find this paper and repo useful, please cite us in your work:

@inproceedings{DBLP:conf/icassp/JinXSL22, author = {Chuhao Jin and Hongteng Xu and Ruihua Song and Zhiwu Lu}, title = {Text2Poster: Laying Out Stylized Texts on Retrieved Images}, booktitle = {{IEEE} International Conference on Acoustics, Speech and Signal Processing, {ICASSP} 2022, Virtual and Singapore, 23-27 May 2022}, pages = {4823--4827}, publisher = {{IEEE}}, year = {2022}, url = {https://doi.org/10.1109/ICASSP43922.2022.9747465}, doi = {10.1109/ICASSP43922.2022.9747465}, timestamp = {Tue, 07 Jun 2022 17:34:56 +0200}, biburl = {https://dblp.org/rec/conf/icassp/JinXSL22.bib}, bibsource = {dblp computer science bibliography, https://dblp.org} }

Contact

My Email is: jinchuhao@ruc.edu.cn

编辑推荐精选

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙��写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

下拉加载更多