/ Модель

Характеристики

Лицензия
OpenRAIL++
Архитектура
ctrl · dense
Библиотека
diffusers
Опубликована
7 июл 2023

qr-code

Преобразование изображенийИзображение, текст → изображение3 профессии

Дообученный ControlNet для Stable Diffusion 1.5, который использует изображение QR-кода как условие для создания стилизованных изображений с сохранением его формы.

130скачиваний за 30 дней4лайкавеса обновлены7 июл 2023

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Это ControlNet для Stable Diffusion 1.5, созданный автором репозитория metafresh89 и дообученный на датасете QR-кодов. Модель принимает изображение QR-кода как условие и направляет генерацию или преобразование изображения, сохраняя форму QR-кода в художественном результате. Репозиторий содержит веса в форматах safetensors и Diffusers; модель предназначена для использования с совместимой базовой моделью Stable Diffusion 1.5 и библиотекой Diffusers или расширением ControlNet для AUTOMATIC1111.

Модель подходит для создания стилизованных изображений с QR-кодом, в том числе рекламных и иллюстративных материалов. Результат зависит от промпта и веса ControlNet: форма кода иногда передаётся неточно, а увеличение веса может ухудшить стиль изображения. Для повышения вероятности сканирования автор рекомендует QR-коды с коррекцией ошибок уровня H и генерацию в разрешении 768 пикселей. Лицензия — OpenRAIL++.

Сценарии применения

  • создание художественных изображений с QR-кодом для рекламы
  • стилизация QR-кода под заданный визуальный стиль
  • генерация иллюстраций с QR-кодом по текстовому промпту

Ограничения

Форма QR-кода может передаваться неточно, и повышение веса ControlNet способно ухудшить стиль результата. Сканируемость не гарантируется и зависит от входного QR-кода, промпта и настроек генерации.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

QR Code Conditioned ControlNet Models for Stable Diffusion 1.5

1

Model Description

This repo holds the safetensors & diffusers versions of the QR code conditioned ControlNet for Stable Diffusion v1.5. The Stable Diffusion 2.1 version is marginally more effective, as it was developed to address my specific needs. However, this 1.5 version model was also trained on the same dataset for those who are using the older version.

How to use with Diffusers

pip -q install diffusers transformers accelerate torch xformers
import torch
from PIL import Image
from diffusers import StableDiffusionControlNetImg2ImgPipeline, ControlNetModel, DDIMScheduler
from diffusers.utils import load_image

controlnet = ControlNetModel.from_pretrained("DionTimmer/controlnet_qrcode-control_v1p_sd15",
                                             torch_dtype=torch.float16)

pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    controlnet=controlnet,
    safety_checker=None,
    torch_dtype=torch.float16
)

pipe.enable_xformers_memory_efficient_attention()
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()

def resize_for_condition_image(input_image: Image, resolution: int):
    input_image = input_image.convert("RGB")
    W, H = input_image.size
    k = float(resolution) / min(H, W)
    H *= k
    W *= k
    H = int(round(H / 64.0)) * 64
    W = int(round(W / 64.0)) * 64
    img = input_image.resize((W, H), resample=Image.LANCZOS)
    return img


# play with guidance_scale, controlnet_conditioning_scale and strength to make a valid QR Code Image

# qr code image
source_image = load_image("https://s3.amazonaws.com/moonup/production/uploads/6064e095abd8d3692e3e2ed6/A_RqHaAM6YHBodPLwqtjn.png")
# initial image, anything
init_image = load_image("https://s3.amazonaws.com/moonup/production/uploads/noauth/KfMBABpOwIuNolv1pe3qX.jpeg")
condition_image = resize_for_condition_image(source_image, 768)
init_image = resize_for_condition_image(init_image, 768)
generator = torch.manual_seed(123121231)
image = pipe(prompt="a bilboard in NYC with a qrcode",
             negative_prompt="ugly, disfigured, low quality, blurry, nsfw", 
             image=init_image,
             control_image=condition_image,
             width=768,
             height=768,
             guidance_scale=20,
             controlnet_conditioning_scale=1.5,
             generator=generator,
             strength=0.9, 
             num_inference_steps=150,
            )

image.images[0]

Performance and Limitations

These models perform quite well in most cases, but please note that they are not 100% accurate. In some instances, the QR code shape might not come through as expected. You can increase the ControlNet weight to emphasize the QR code shape. However, be cautious as this might negatively impact the style of your output.To optimize for scanning, please generate your QR codes with correction mode 'H' (30%).

To balance between style and shape, a gentle fine-tuning of the control weight might be required based on the individual input and the desired output, aswell as the correct prompt. Some prompts do not work until you increase the weight by a lot. The process of finding the right balance between these factors is part art and part science. For the best results, it is recommended to generate your artwork at a resolution of 768. This allows for a higher level of detail in the final product, enhancing the quality and effectiveness of the QR code-based artwork.

Installation

The simplest way to use this is to place the .safetensors model and its .yaml config file in the folder where your other controlnet models are installed, which varies per application. For usage in auto1111 they can be placed in the webui/models/ControlNet folder. They can be loaded using the controlnet webui extension which you can install through the extensions tab in the webui (https://github.com/Mikubill/sd-webui-controlnet). Make sure to enable your controlnet unit and set your input image as the QR code. Set the model to either the SD2.1 or 1.5 version depending on your base stable diffusion model, or it will error. No pre-processor is needed, though you can use the invert pre-processor for a different variation of results. 768 is the preferred resolution for generation since it allows for more detail. Make sure to look up additional info on how to use controlnet if you get stuck, once you have the webui up and running its really easy to install the controlnet extension aswell.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · diffusers

Нельзя запустить

Модели «картинка → картинка» пока не запускаются.

Ревизия весов
12b99cc

0 моделей