error402 commited on
Commit
fd5a5f9
1 Parent(s): 4ca3cf8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -96
README.md CHANGED
@@ -1,96 +0,0 @@
1
- ---
2
- tags:
3
- - stable-diffusion
4
- - controlnet
5
- - image-to-image
6
- license: openrail++
7
- language:
8
- - en
9
- library_name: diffusers
10
- pipeline_tag: image-to-image
11
- ---
12
- # QR Code Conditioned ControlNet Models for Stable Diffusion 1.5
13
-
14
- ![1](https://www.dropbox.com/s/fxyuqpot2z2ftty/5.png?raw=1)
15
-
16
- ## Model Description
17
-
18
- This repo holds the safetensors & diffusers versions of the QR code conditioned ControlNet for Stable Diffusion v1.5.
19
- 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.
20
-
21
- ## How to use with Diffusers
22
-
23
-
24
- ```bash
25
- pip -q install diffusers transformers accelerate torch xformers
26
- ```
27
-
28
- ```python
29
- import torch
30
- from PIL import Image
31
- from diffusers import StableDiffusionControlNetImg2ImgPipeline, ControlNetModel, DDIMScheduler
32
- from diffusers.utils import load_image
33
-
34
- controlnet = ControlNetModel.from_pretrained("DionTimmer/controlnet_qrcode-control_v1p_sd15",
35
- torch_dtype=torch.float16)
36
-
37
- pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
38
- "runwayml/stable-diffusion-v1-5",
39
- controlnet=controlnet,
40
- safety_checker=None,
41
- torch_dtype=torch.float16
42
- )
43
-
44
- pipe.enable_xformers_memory_efficient_attention()
45
- pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
46
- pipe.enable_model_cpu_offload()
47
-
48
- def resize_for_condition_image(input_image: Image, resolution: int):
49
- input_image = input_image.convert("RGB")
50
- W, H = input_image.size
51
- k = float(resolution) / min(H, W)
52
- H *= k
53
- W *= k
54
- H = int(round(H / 64.0)) * 64
55
- W = int(round(W / 64.0)) * 64
56
- img = input_image.resize((W, H), resample=Image.LANCZOS)
57
- return img
58
-
59
-
60
- # play with guidance_scale, controlnet_conditioning_scale and strength to make a valid QR Code Image
61
-
62
- # qr code image
63
- source_image = load_image("https://s3.amazonaws.com/moonup/production/uploads/6064e095abd8d3692e3e2ed6/A_RqHaAM6YHBodPLwqtjn.png")
64
- # initial image, anything
65
- init_image = load_image("https://s3.amazonaws.com/moonup/production/uploads/noauth/KfMBABpOwIuNolv1pe3qX.jpeg")
66
- condition_image = resize_for_condition_image(source_image, 768)
67
- init_image = resize_for_condition_image(init_image, 768)
68
- generator = torch.manual_seed(123121231)
69
- image = pipe(prompt="a bilboard in NYC with a qrcode",
70
- negative_prompt="ugly, disfigured, low quality, blurry, nsfw",
71
- image=init_image,
72
- control_image=condition_image,
73
- width=768,
74
- height=768,
75
- guidance_scale=20,
76
- controlnet_conditioning_scale=1.5,
77
- generator=generator,
78
- strength=0.9,
79
- num_inference_steps=150,
80
- )
81
-
82
- image.images[0]
83
-
84
- ```
85
-
86
- ## Performance and Limitations
87
-
88
- 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%).**
89
-
90
- 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.
91
-
92
- ## Installation
93
-
94
- 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.
95
- 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.
96
- 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.