Instructions to use custom-diffusion-library/cat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use custom-diffusion-library/cat with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("custom-diffusion-library/cat", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| license: other | |
| tags: | |
| - pytorch | |
| - stable-diffusion | |
| - stable-diffusion-diffusers | |
| - diffusers | |
| # This is a Custom Diffusion model fine-tuned from the Stable Diffusion v1-4. | |
| [Custom Diffusion](https://www.cs.cmu.edu/~custom-diffusion/index.html) allows you to fine-tune text-to-image diffusion models, such as Stable Diffusion, given a few images of a new concept (~4-20). | |
| Here we give an example model fine-tuned using 5 images of a cat downloaded from UnSplash. The example code of inference is shown below. | |
| ## Example code of inference | |
| ``` | |
| git clone https://github.com/adobe-research/custom-diffusion | |
| cd custom-diffusion | |
| ``` | |
| ```python | |
| from diffusers import StableDiffusionPipeline | |
| from src import diffuser_training | |
| device = 'cuda' | |
| model_id = "CompVis/stable-diffusion-v1-4" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
| pipe = pipe.to(device) | |
| diffuser_training.load_model(pipe.text_encoder, pipe.tokenizer, pipe.unet, 'cat.bin') | |
| prompt = "<new1> cat swimming in a pool" | |
| images = pipe(prompt, num_inference_steps=200, guidance_scale=6., eta=1.).images | |
| ``` | |
| <center> | |
| <img src="https://huggingface.co/custom-diffusion-library/cat/resolve/main/cat.png" width="600" align="center" > | |
| </center> | |