Instructions to use zeyuren2002/EvalMDE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use zeyuren2002/EvalMDE with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("zeyuren2002/EvalMDE", 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
| from typing import List | |
| import numpy as np | |
| import torch | |
| import torch.nn.functional as F | |
| def get_angle_between(n1: torch.Tensor, n2: torch.Tensor) -> torch.Tensor: | |
| ''' | |
| :param n1: shape (..., 3), norm > 0 | |
| :param n2: shape (..., 3), norm > 0 | |
| :return: shape (...), in radius | |
| ''' | |
| return torch.acos((F.normalize(n1, dim=-1) * F.normalize(n2, dim=-1)).sum(dim=-1).clamp(-1, 1)) | |
| def reformat_as_torch_tensor(x, device=torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')): | |
| if isinstance(x, List): | |
| return torch.tensor(x, device=device) | |
| elif isinstance(x, np.ndarray): | |
| return torch.from_numpy(x).to(device=device) | |
| elif isinstance(x, torch.Tensor): | |
| return x.to(device=device) | |
| else: | |
| raise ValueError(f'Unsupported type: {type(x)}') | |