---
title: sdxl-wrong
canonical_url: "https://www.modelscope.cn/models/fofr/sdxl-wrong"
md_url: "https://www.modelscope.cn/models/fofr/sdxl-wrong.md"
repository: fofr/sdxl-wrong
last_updated: 2024-12-17
license: creativeml-openrail-m
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
base_model:
  - stabilityai/stable-diffusion-xl-base-1.0
base_model_relation: adapter
parameters: 46.4M
tensor_type:
  - F32
library_name:
  - pytorch
  - lora
  - diffusers
  - safetensors
frameworks:
  - pytorch
downloads: 1194
stars: 0
tags:
  - text-to-image
  - stable-diffusion
  - lora
  - diffusers
---

# sdxl-wrong

> sdxl-wrong - fofr 在 ModelScope 开源的模型。sdxl-wrong LoRA by fofr An SDXL fine-tune on bad 2048x2048 images

fofr/sdxl-wrong 是 ModelScope 魔搭社区上的 46.4M 参数text-to-image-synthesis模型，采用 creativeml-openrail-m 许可，基于 stabilityai/stable-diffusion-xl-base-1.0 构建。

- **Repository**: fofr/sdxl-wrong
- **License**: creativeml-openrail-m
- **Tasks**: text-to-image-synthesis
- **Parameters**: 46.4M
- **Base model**: stabilityai/stable-diffusion-xl-base-1.0
- **Tags**: text-to-image, stable-diffusion, lora, diffusers
- **Downloads**: 1194
- **Stars**: 0
- **Last updated**: 2024-12-17

Source: https://www.modelscope.cn/models/fofr/sdxl-wrong

---

# sdxl-wrong LoRA by [fofr](https://replicate.com/fofr)
### An SDXL fine-tune on bad 2048x2048 images

![lora_image](https://pbxt.replicate.delivery/fc5IBfqQyGhfeSfUfI0zTdaf1gBpmb00k1O94vlojIp0V5E0IA/out-0.png)
>

## Inference with Replicate API
Grab your replicate token [here](https://replicate.com/account)
```bash
pip install replicate
export REPLICATE_API_TOKEN=r8_*************************************
```

```py
import replicate

output = replicate.run(
    "sdxl-wrong@sha256:164e357b3d844b3023b7467f84b9da9534c58a43f2588b60bb77eb0d51f41ec0",
    input={"prompt": "A TOK image"}
)
print(output)
```
You may also do inference via the API with Node.js or curl, and locally with COG and Docker, [check out the Replicate API page for this model](https://replicate.com/fofr/sdxl-wrong/api)

## Inference with 🧨 diffusers
Replicate SDXL LoRAs are trained with Pivotal Tuning, which combines training a concept via Dreambooth LoRA with training a new token with Textual Inversion.
As `diffusers` doesn't yet support textual inversion for SDXL, we will use cog-sdxl `TokenEmbeddingsHandler` class.

The trigger tokens for your prompt will be `<s0><s1>`

```shell
pip install diffusers transformers accelerate safetensors huggingface_hub
git clone https://github.com/replicate/cog-sdxl cog_sdxl
```

```py
import torch
from huggingface_hub import hf_hub_download
from diffusers import DiffusionPipeline
from cog_sdxl.dataset_and_utils import TokenEmbeddingsHandler
from diffusers.models import AutoencoderKL

pipe = DiffusionPipeline.from_pretrained(
        "stabilityai/stable-diffusion-xl-base-1.0",
        torch_dtype=torch.float16,
        variant="fp16",
).to("cuda")

pipe.load_lora_weights("fofr/sdxl-wrong", weight_name="lora.safetensors")

text_encoders = [pipe.text_encoder, pipe.text_encoder_2]
tokenizers = [pipe.tokenizer, pipe.tokenizer_2]

embedding_path = hf_hub_download(repo_id="fofr/sdxl-wrong", filename="embeddings.pti", repo_type="model")
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
embhandler.load_embeddings(embedding_path)
prompt="A <s0><s1> image"
images = pipe(
    prompt,
    cross_attention_kwargs={"scale": 0.8},
).images
#your output image
images[0]
```
