Image-to-Image
Diffusers
StableDiffusionImageVariationPipeline
stable-diffusion
stable-diffusion-diffusers
Run this model with HF Jobs
Run lambda/sd-image-variations-diffusers on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/lambda/sd-image-variations-diffusers. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/lambda/sd-image-variations-diffusers on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use lambda/sd-image-variations-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use lambda/sd-image-variations-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("lambda/sd-image-variations-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Commit ·
ff5cc82
1
Parent(s): a430b6b
Update README.md
Browse files10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555683 unmodified lines14014114214310 unmodified lines# Stable Diffusion Image Variations Model CardThis version of Stable Diffusion has been fine tuned from [CompVis/stable-diffusion-v1-3-original](https://huggingface.co/CompVis/stable-diffusion-v-1-3-original) to accept CLIP image embedding rather than text embeddings. This allows the creation of "image variations" similar to DALLE-2 using Stable Diffusion. This version of the weights has been ported to huggingface Diffusers, to use this with the Diffusers library requires the [Lambda Diffusers repo](https://github.com/LambdaLabsML/lambda-diffusers).## ExampleFirst clone [Lambda Diffusers](https://github.com/LambdaLabsML/lambda-diffusers) and install any requirements (in a virtual environment in the example below):```bashgit clone https://github.com/LambdaLabsML/lambda-diffusers.gitcd lambda-diffuserspython -m venv .venvsource .venv/bin/activatepip install -r requirements.txt```Then run the following python code:```pythonfrom pathlib import Pathfrom lambda_diffusers import StableDiffusionImageEmbedPipelinefrom PIL import Imageimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"pipe = StableDiffusionImageEmbedPipeline.from_pretrained("lambdalabs/sd-image-variations-diffusers")pipe = pipe.to(device)im = Image.open("your/input/image/here.jpg")num_samples = 4image = pipe(num_samples*[im], guidance_scale=3.0)image = image["sample"]base_path = Path("outputs/im2im")base_path.mkdir(exist_ok=True, parents=True)for idx, im in enumerate(image):im.save(base_path/f"{idx:06}.jpg")```# Training**Training Data**83 unmodified linesThe concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.*This model card was written by: Justin Pinkney and is based on the [Stable Diffusion model card](https://huggingface.co/CompVis/stable-diffusion-v1-4).*10 unmodified lines11121314151617181920212223242526272829303132333435363783 unmodified lines12112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716810 unmodified lines# Stable Diffusion Image Variations Model Card🧨🎉 Image Variations is now natively supported in 🤗 Diffusers! 🎉🧨This version of Stable Diffusion has been fine tuned from [CompVis/stable-diffusion-v1-3-original](https://huggingface.co/CompVis/stable-diffusion-v-1-3-original) to accept CLIP image embedding rather than text embeddings. This allows the creation of "image variations" similar to DALLE-2 using Stable Diffusion. This version of the weights has been ported to huggingface Diffusers, to use this with the Diffusers library requires the [Lambda Diffusers repo](https://github.com/LambdaLabsML/lambda-diffusers).## ExampleMake sure you are using a version of Diffusers >=0.8.0 (for older version see the old instructions at the bottom of this model card)```pythonfrom diffusers import StableDiffusionImageVariationPipelinefrom PIL import Imagedevice = "cuda:0"sd_pipe = StableDiffusionImageVariationPipeline.from_pretrained("lambdalabs/sd-image-variations-diffusers")sd_pipe = sd_pipe.to(device)out = sd_pipe(image=Image.open("path/to/image.jpg"))out["images"][0].save("result.jpg")```# Training**Training Data**83 unmodified linesThe concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.## Old instructionsIf you are using a diffusers version <0.8.0 there is no `StableDiffusionImageVariationPipeline`,in this case you need to use an older revision (`2ddbd90b14bc5892c19925b15185e561bc8e5d0a`) in conjunction with the lambda-diffusers repo:First clone [Lambda Diffusers](https://github.com/LambdaLabsML/lambda-diffusers) and install any requirements (in a virtual environment in the example below):```bashgit clone https://github.com/LambdaLabsML/lambda-diffusers.gitcd lambda-diffuserspython -m venv .venvsource .venv/bin/activatepip install -r requirements.txt```Then run the following python code:```pythonfrom pathlib import Pathfrom lambda_diffusers import StableDiffusionImageEmbedPipelinefrom PIL import Imageimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"pipe = StableDiffusionImageEmbedPipeline.from_pretrained("lambdalabs/sd-image-variations-diffusers",revision="2ddbd90b14bc5892c19925b15185e561bc8e5d0a",)pipe = pipe.to(device)im = Image.open("your/input/image/here.jpg")num_samples = 4image = pipe(num_samples*[im], guidance_scale=3.0)image = image["sample"]base_path = Path("outputs/im2im")base_path.mkdir(exist_ok=True, parents=True)for idx, im in enumerate(image):im.save(base_path/f"{idx:06}.jpg")```*This model card was written by: Justin Pinkney and is based on the [Stable Diffusion model card](https://huggingface.co/CompVis/stable-diffusion-v1-4).*
README.md+53-28