当前位置: 首页 > article >正文

文生图模型

CogView3/README_zh.md at main · THUDM/CogView3 · GitHub

快速开始

提示词优化

虽然 CogView3 系列模型都是通过长篇合成图像描述进行训练的,但我们强烈建议在文本生成图像之前,基于大语言模型(LLMs)进行提示词的重写操作,这将大大提高生成质量。

我们提供了一个 示例脚本。我们建议您运行这个脚本,以实现对提示词对润色

python prompt_optimize.py --api_key "智谱AI API Key" --prompt {你的提示词} --base_url "https://open.bigmodel.cn/api/paas/v4" --model "glm-4-plus"

推理模型(Diffusers)

首先,确保从源代码安装diffusers库。

pip install git+https://github.com/huggingface/diffusers.git

接着,运行以下代码:

from diffusers import CogView3PlusPipeline
import torch

pipe = CogView3PlusPipeline.from_pretrained("THUDM/CogView3-Plus-3B", torch_dtype=torch.float16).to("cuda")

# Open it for reduce GPU memory usage
pipe.enable_model_cpu_offload()
pipe.vae.enable_slicing()
pipe.vae.enable_tiling()

prompt = "A vibrant cherry red sports car sits proudly under the gleaming sun, its polished exterior smooth and flawless, casting a mirror-like reflection. The car features a low, aerodynamic body, angular headlights that gaze forward like predatory eyes, and a set of black, high-gloss racing rims that contrast starkly with the red. A subtle hint of chrome embellishes the grille and exhaust, while the tinted windows suggest a luxurious and private interior. The scene conveys a sense of speed and elegance, the car appearing as if it's about to burst into a sprint along a coastal road, with the ocean's azure waves crashing in the background."
image = pipe(
    prompt=prompt,
    guidance_scale=7.0,
    num_images_per_prompt=1,
    num_inference_steps=50,
    width=1024,
    height=1024,
).images[0]

image.save("cogview3.png")


http://www.kler.cn/news/355897.html

相关文章:

  • 【Windows】DevOps PowerShell实现读取ini文件 生成登陆凭证 发送文件到远程服务器 远程服务器执行指令 实现fabric1的基础功能
  • 【论文阅读】Bi-Mamba+: Bidirectional Mamba for Time Series Forecasting
  • Flutter 与 React Native - 详细深入对比分析(2024 年)
  • 六万字77道Spring面试题总结(2024版)
  • WPF基础权限系统
  • C++内存对齐机制简介
  • 纯css 轮播图片,鼠标移入暂停 移除继续
  • C++初阶
  • 云服务解决方案,针对小程序、网页、HTML5等轻量化视频解决方案
  • (42)MATLAB中使用fftshift绘制以零为中心的功率谱
  • Python 网络编程:端口检测与IP解析
  • OBOO鸥柏自助服务终端:开启智慧城市便民新篇章
  • 【前端学习】AntV G6-09 复杂的自定义边、边动画
  • 模块化JS + OpenAI 手搓数据分析项目
  • 力扣 83.删除排序链表中的重复元素
  • Linux 系统上生成大文件的多种方法
  • mysql操作详解
  • Linux安装 php5.6
  • java线程池bug的一些思考
  • 如何在word里面给文字加拼音?