Instructions to use metafresh89/qr-code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use metafresh89/qr-code with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("metafresh89/qr-code") pipe = StableDiffusionControlNetPipeline.from_pretrained( "fill-in-base-model", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
| from typing import Dict, List, Any | |
| from PIL import Image | |
| from io import BytesIO | |
| from transformers import pipeline | |
| import base64 | |
| class EndpointHandler(): | |
| def __init__(self, path=""): | |
| self.pipeline=pipeline("controlnet_qrcode-control_v11p_sd21",model=path) | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: | |
| """ | |
| data args: | |
| images (:obj:`string`) | |
| candiates (:obj:`list`) | |
| Return: | |
| A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82} | |
| """ | |
| inputs = data.pop("inputs", data) | |
| prompts = data.pop("prompt", data) | |
| image = Image.open(BytesIO(base64.b64decode(inputs['image']))) | |
| # run prediction one image wit provided candiates | |
| prediction = self.pipeline(images=[image], prompt=[prompts]) | |
| return prediction[0] |