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
| import numpy as np | |
| import matplotlib | |
| import torch | |
| def visualize_depth(depth: np.ndarray, | |
| depth_min=None, | |
| depth_max=None, | |
| percentile=2, | |
| ret_minmax=False, | |
| cmap='Spectral'): | |
| if depth_min is None: depth_min = np.percentile(depth, percentile) | |
| if depth_max is None: depth_max = np.percentile(depth, 100 - percentile) | |
| if depth_min == depth_max: | |
| depth_min = depth_min - 1e-6 | |
| depth_max = depth_max + 1e-6 | |
| cm = matplotlib.colormaps[cmap] | |
| depth = ((depth - depth_min) / (depth_max - depth_min)).clip(0, 1) | |
| img_colored_np = cm(depth, bytes=False)[:, :, 0:3] # value from 0 to 1 | |
| if ret_minmax: | |
| return img_colored_np, depth_min, depth_max | |
| else: | |
| return img_colored_np | |