stable diffusion base 2.0 text to image 04

提供商mhbkb
分类image-generation
许可证creativeml-openrail-m
下载量8
星标0

简介

Stable Diffusion v2.0 是一个经典的开源文本生成图像模型。相比 1.5 版本,它在图像分辨率和细节刻画上有了显著提升,能够生成更具现代感和清晰度的画面。对于中国开发者而言,它最大的价值在于其强大的生态兼容性,可以通过 LoRA、ControlNet 等插件进行精准控制。虽然对提示词(Prompt)的精准度要求比 v1.5 更高,上手稍有门槛,但它在建筑设计、产品概念图和高质量素材生成方面表现稳健,是搭建自有图像生成流水线的理想基础模型。

核心亮点

  • 原生支持更高分辨率,图像细节更丰富
  • 开源生态极强,支持大量第三方插件微调
  • 适用于建筑、工业设计等专业视觉创作
  • 低硬件门槛,支持本地部署与私有化运行

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("mhbkb/stable-diffusion-base-2.0-text-to-image-04")
tokenizer = AutoTokenizer.from_pretrained("mhbkb/stable-diffusion-base-2.0-text-to-image-04")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download mhbkb/stable-diffusion-base-2.0-text-to-image-04

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download mhbkb/stable-diffusion-base-2.0-text-to-image-04 config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('mhbkb/stable-diffusion-base-2.0-text-to-image-04')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/mhbkb/stable-diffusion-base-2.0-text-to-image-04

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/mhbkb/stable-diffusion-base-2.0-text-to-image-04

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('mhbkb/stable-diffusion-base-2.0-text-to-image-04')
tokenizer = AutoTokenizer.from_pretrained('mhbkb/stable-diffusion-base-2.0-text-to-image-04')

完整文档

来源: HuggingFace

---
base_model: stabilityai/stable-diffusion-2
library_name: diffusers
license: creativeml-openrail-m
inference: true
tags:

  • stable-diffusion

  • stable-diffusion-diffusers

  • text-to-image

  • diffusers

  • diffusers-training

---

<!-- This model card has been generated automatically according to the information the training script had access to. You
should probably proofread and complete it, then remove this comment. -->

Text-to-image finetuning - mhbkb/stable-diffusion-base-2.0-text-to-image-04

This pipeline was finetuned from stabilityai/stable-diffusion-2 on the None dataset. Below are some example images generated with the finetuned pipeline using the following prompts: ['a photo of a dog']:

!val_imgs_grid

Pipeline usage

You can use the pipeline like so:

python
from diffusers import DiffusionPipeline
import torch

pipeline = DiffusionPipeline.from_pretrained("mhbkb/stable-diffusion-base-2.0-text-to-image-04", torch_dtype=torch.float16)
prompt = "a photo of a dog"
image = pipeline(prompt).images[0]
image.save("my_image.png")

Training info

These are the key hyperparameters used during training:

  • Epochs: 8
  • Learning rate: 0.0001
  • Batch size: 1
  • Gradient accumulation steps: 4
  • Image resolution: 768
  • Mixed-precision: fp16

More information on all the CLI arguments and the environment are available on your wandb run page.

Intended uses & limitations

#### How to use

python
# TODO: add an example code snippet for running this diffusion pipeline

#### Limitations and bias

[TODO: provide examples of latent issues and potential remediations]

Training details

[TODO: describe the data used to train the model]