Instructions to use limingcv/reward_controlnet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use limingcv/reward_controlnet with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("limingcv/reward_controlnet", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| import cv2 | |
| import numpy as np | |
| def resize_image(input_image, resolution, interpolation=None): | |
| H, W, C = input_image.shape | |
| H = float(H) | |
| W = float(W) | |
| k = float(resolution) / max(H, W) | |
| H *= k | |
| W *= k | |
| H = int(np.round(H / 64.0)) * 64 | |
| W = int(np.round(W / 64.0)) * 64 | |
| if interpolation is None: | |
| interpolation = cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA | |
| img = cv2.resize(input_image, (W, H), interpolation=interpolation) | |
| return img | |