stable diffusion base 2.0 text to image 04
简介
核心亮点
- 原生支持更高分辨率,图像细节更丰富
- 开源生态极强,支持大量第三方插件微调
- 适用于建筑、工业设计等专业视觉创作
- 低硬件门槛,支持本地部署与私有化运行
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 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 目录为例)
huggingface-cli download mhbkb/stable-diffusion-base-2.0-text-to-image-04 config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('mhbkb/stable-diffusion-base-2.0-text-to-image-04')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/mhbkb/stable-diffusion-base-2.0-text-to-image-04
如果您希望跳过 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
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')
完整文档
---
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']:
Pipeline usage
You can use the pipeline like so:
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
# 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]