Run this model with HF Jobs
Run jacklishufan/diffusion-kto 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/jacklishufan/diffusion-kto. 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/jacklishufan/diffusion-kto 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 jacklishufan/diffusion-kto with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use jacklishufan/diffusion-kto with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("jacklishufan/diffusion-kto", 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
Create README.md
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---datasets:- yuvalkirstain/pickapic_v2library_name: diffusers---# Diffusion-KTO: Aligning Diffusion Models by Optimizing Human Utility<p align="center"> <img src="https://github.com/jacklishufan/diffusion-kto/blob/main/assets/teaser.png?raw=true", width=60%> <br></p>
This model is fine-tuned from stable-diffusion-xl-base-1.0 on offline human preference data pickapic_v2 using KTO.
### Usage```import torchfrom diffusers import AutoencoderKL, UNet2DConditionModel, DiffusionPipelinevae_path = model_name = "runwayml/stable-diffusion-v1-5"device = 'cuda'weight_dtype = torch.float16vae = AutoencoderKL.from_pretrained( vae_path, subfolder="vae",)unet = UNet2DConditionModel.from_pretrained( "jacklishufan/diffusion-kto", subfolder="unet",)pipeline = DiffusionPipeline.from_pretrained( model_name, vae=vae, unet=unet, device=device,).to(device).to(weight_dtype)
result = pipeline( prompt="Self-portrait oil painting, a beautiful cyborg with golden hair, 8k", num_inference_steps=50, guidance_scale=7.0)img = result[0][0]```### Code
The code is available [here](https://github.com/jacklishufan/diffusion-kto)
### Citation```@misc{li2024aligning, title={Aligning Diffusion Models by Optimizing Human Utility}, author={Shufan Li and Konstantinos Kallidromitis and Akash Gokul and Yusuke Kato and Kazuki Kozuka}, year={2024}, eprint={2404.04465}, archivePrefix={arXiv}, primaryClass={cs.CV}}```README.mdAdded+58