CogView4-6B-安装体验

目录

步骤一、下载模型

步骤二、写代码执行-英文提示词

步骤三、写代码执行-中文提示词


步骤一、下载模型

下载模型
modelscope download --model ZhipuAI/CogView4-6B --local_dir /root/autodl-tmp/ZhipuAI/CogView4-6B


安装依赖
pip install git+https://github.com/huggingface/diffusers.git

步骤二、写代码执行-英文提示词

可以成功执行的代码

from modelscope import CogView4Pipeline
from modelscope import snapshot_download
import torch

pipe = CogView4Pipeline.from_pretrained("/root/autodl-tmp/ZhipuAI/CogView4-6B", torch_dtype=torch.bfloat16)

# 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=3.5,
    num_images_per_prompt=1,
    num_inference_steps=50,
    width=1024,
    height=1024,
).images[0]

image.save("cogview4.png")

步骤三、写代码执行-中文提示词

from modelscope import CogView4Pipeline
from modelscope import snapshot_download
import torch

pipe = CogView4Pipeline.from_pretrained("/root/autodl-tmp/ZhipuAI/CogView4-6B", torch_dtype=torch.bfloat16)

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

prompt = "一辆充满活力的绿色跑车自豪地坐在闪闪发光的阳光下,其抛光的外观光滑无瑕,投射出镜面般的倒影。这款车的特点是低矮的空气动力学车身,有棱角的前灯,像掠食性的眼睛一样向前看,还有一套与绿色形成鲜明对比的黑色高光泽赛车轮圈。格栅和排气口上微妙的铬装饰,而有色窗户则暗示着豪华而私密的内饰。这一场景传达了一种速度和优雅的感觉,汽车看起来就像要沿着一条沿海公路冲刺,背景是大海湛蓝的海浪。"
image = pipe(
    prompt=prompt,
    guidance_scale=3.5,
    num_images_per_prompt=1,
    num_inference_steps=50,
    width=1024,
    height=1024,
).images[0]

image.save("cogview4-2.png")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张3蜂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值