最近在研究HuggingFace,发现了好多有趣的模型,借助其免费的资源可以实现自己画家的小爱好
给出一个例子
1. 铅笔画模型 https://huggingface.co/Datou1111/shou_xin,其可以使用接口进行调用使用手法我这边编写了一个非常简单的脚本
from huggingface_hub import InferenceClient
import os
import uuid
proxy_url = "http://127.0.0.1:7890"
# 设置环境变量以使用代理
os.environ['HTTP_PROXY'] = proxy_url
os.environ['HTTPS_PROXY'] = proxy_url
client = InferenceClient("Datou1111/shou_xin", token="hf_n")
prompts = [ "shou_xin, an office worker sitting at their desk, looking at the computer screen, preparing to stand up, office environment, ink wash painting, minimalistic, impressionism, negative space, focused atmosphere.", "shou_xin, the office worker now standing up from their chair, gathering their belongings, ready to leave, office environment, ink wash, minimalistic, impressionism, negative space, transitional movement.", "shou_xin, the office worker walking out of the office, carrying a bag or briefcase, looking forward, office environment, ink wash, minimalistic, impressionism, negative space, sense of departure." ]
# output is a PIL.Image object
for prompt in prompts:
image = client.text_to_image(prompt)
image.save("output_image_" + str(uuid.uuid4()) + ".png")
2. 提示词可以使用其他的AI模型来生成,我是使用的自己写的平台
3. 然后将连续生成的图片在拼接成一幅图,就形成了类似于漫画的图片,当然拼接也是使用我自己的平台
4. 最终生成的效果如下