2024-11-11
深度学习
00

Dockerfile环境:

bash
FROM dockerpull.org/pytorch/pytorch:2.4.0-cuda12.1-cudnn9-devel RUN pip install diffusers -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple RUN pip install gradio uvicorn RUN pip install transformers -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple RUN pip install accelerate sentencepiece ftfy openai -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple WORKDIR /app COPY ./scripts /app/scripts RUN chmod +x /app/scripts/entrypoint.sh EXPOSE 7860 ENTRYPOINT ["/app/scripts/entrypoint.sh"]

推理代码:

python
import torch from diffusers import PixArtAlphaPipeline device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model_path = "/ssd/xiedong/PixArt-alpha/output/model_diffusers_caidao" pipe = PixArtAlphaPipeline.from_pretrained(model_path, torch_dtype=torch.float16, use_safetensors=True) pipe.to(device) prompt = "Spoiling things through excessive enthusiasm" image = pipe(prompt=prompt, negative_prompt="paintings, sketches, (worst quality, low quality, normal quality:1.7), \nlowres, blurry, text, logo, monochrome, grayscale, skin spots, acnes, skin blemishes, \nage spot, strabismus, wrong finger, bad anatomy, bad hands, error, missing fingers, cropped, \njpeg artifacts, signature, watermark, username, (dark skin:1.1), fused girls, fushion, bad-hands-5, \nugly, pregnant, vore, duplicate, morbid, mutilated, tran nsexual, hermaphrodite, long neck, \nmutated hands, poorly drawn face, mutation, deformed, bad proportions, malformed limbs, extra limbs,\ncloned face, disfigured, gross proportions, (missing arms:1.331), (missing legs:1.331), \n(extra arms:1.331), (extra legs:1.331), plump, bad legs, fewer digits, (open month:2),(tooth:2),(teeth:2), \nNegro, black people, black race", num_inference_steps=20 ).images[0] rgb_image = image.convert("RGB") rgb_image.save("./acat.jpg")

出问题:

Setting clean_caption=True requires the ftfy library but it was not found in your environment. Checkout the instructions on the installation section: https://github.com/rspeer/python-ftfy/tree/master#installing and follow the ones that match your environment. Please note that you may need to restart your runtime after installation.

这样超过tokens限制:

bash
pil_image = pipe(prompt=prompt, negative_prompt=negative_prompt, num_inference_steps=20, max_sequence_length=200 ).images[0]
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:Dong

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!