Instructions to use ghoskno/Fake-QRcode with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ghoskno/Fake-QRcode 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("ghoskno/Fake-QRcode", torch_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
| library_name: diffusers | |
| license: apache-2.0 | |
| language: | |
| - en | |
| pipeline_tag: image-to-image | |
| # Fake-QRcode ControlNet | |
| These are ControlNet checkpoints trained on runwayml/stable-diffusion-v1-5 to generate recognizable AIGC QRcode image. | |
| ## Model Details | |
| Details will be added soon... | |
| ## Use with diffusers | |
| See the snippet below for usage with diffusers: | |
| ```python | |
| import cv2 | |
| import numpy as np | |
| import torch | |
| import os, sys | |
| from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, AutoencoderKL, EulerAncestralDiscreteScheduler | |
| from PIL import Image | |
| controlnet = ControlNetModel.from_pretrained("ghoskno/Fake-Qrcode") | |
| pipe = StableDiffusionControlNetPipeline.from_pretrained( | |
| "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16 | |
| ) | |
| pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload() | |
| generator = torch.manual_seed(412052000) | |
| qrcode = cv2.imread('path_to_qrcode.png') | |
| qrcode = cv2.resize(255 - qrcode, (1024, 1024)) | |
| image = pipe( | |
| "Blooming chinese chrysanthemum, green leaves growing wantonly, flowers, Complex patterns on the border, Masterpiece Art, Beauty, 8K, Unreal Engine", | |
| Image.fromarray(qrcode), | |
| generator=generator, | |
| num_inference_steps=37, | |
| guidance_scale=7, | |
| controlnet_conditioning_scale=1.85 | |
| ).images[0] | |
| ``` | |
| ## Some examples | |
| **input qrcode image** | |
| <img src="./ghoskno.png" style="zoom: 33%;" /> | |
| **prompt**: Blooming chinese chrysanthemum, green leaves growing wantonly, flowers, Complex patterns on the border, Masterpiece Art, Beauty, 8K, Unreal Engine | |
| <img src="./1.jpg" style="zoom: 33%;" /> | |
| **prompt**: Plum blossoms in the snow, pink stamens, green leaves and branches growing wantonly, flowers, Complex patterns on the border, Masterpiece Art, Beauty, 8K, Unreal Engine | |
| <img src="./2.jpg" style="zoom: 33%;" /> | |
| ## Limitations and Bias | |
| - No strict control by input prompt | |
| - Sometimes generate confusion or generate unrecognizable QRcode images | |