Instructions to use b3h-young123/slected-space with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use b3h-young123/slected-space with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("b3h-young123/slected-space", 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 torch | |
| import torch.nn as nn | |
| backwarp_tenGrid = {} | |
| def warp(tenInput, tenFlow): | |
| device = tenFlow.device | |
| k = (str(tenFlow.device), str(tenFlow.size())) | |
| if k not in backwarp_tenGrid: | |
| tenHorizontal = torch.linspace(-1.0, 1.0, tenFlow.shape[3], device=device).view( | |
| 1, 1, 1, tenFlow.shape[3]).expand(tenFlow.shape[0], -1, tenFlow.shape[2], -1) | |
| tenVertical = torch.linspace(-1.0, 1.0, tenFlow.shape[2], device=device).view( | |
| 1, 1, tenFlow.shape[2], 1).expand(tenFlow.shape[0], -1, -1, tenFlow.shape[3]) | |
| backwarp_tenGrid[k] = torch.cat( | |
| [tenHorizontal, tenVertical], 1).to(device) | |
| tenFlow = torch.cat([tenFlow[:, 0:1, :, :] / ((tenInput.shape[3] - 1.0) / 2.0), | |
| tenFlow[:, 1:2, :, :] / ((tenInput.shape[2] - 1.0) / 2.0)], 1) | |
| g = (backwarp_tenGrid[k] + tenFlow).permute(0, 2, 3, 1) | |
| return torch.nn.functional.grid_sample(input=tenInput, grid=g, mode='bilinear', padding_mode='border', align_corners=True) | |