Instructions to use phi-lab-rice/GRADE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use phi-lab-rice/GRADE with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("phi-lab-rice/GRADE", 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
Download src/Baselines/radarcam-depth/utils/eval_utils.py from phi-lab-rice/GRADE: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/phi-lab-rice/GRADE/resolve/main/src/Baselines/radarcam-depth/utils/eval_utils.py
- Command line
-
hf download hf://phi-lab-rice/GRADE/src/Baselines/radarcam-depth/utils/eval_utils.py
-
curl -L -o eval_utils.py https://huggingface.co/phi-lab-rice/GRADE/resolve/main/src/Baselines/radarcam-depth/utils/eval_utils.py
2.37 kB
| """Metric utilities used by the RadarCam-Depth evaluation backend.""" | |
| import numpy as np | |
| def root_mean_sq_err(src, tgt): | |
| ''' | |
| Root mean squared error | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : root mean squared error | |
| ''' | |
| return np.sqrt(np.mean((tgt - src) ** 2)) | |
| def mean_abs_err(src, tgt): | |
| ''' | |
| Mean absolute error | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : mean absolute error | |
| ''' | |
| return np.mean(np.abs(tgt - src)) | |
| def inv_root_mean_sq_err(src, tgt): | |
| ''' | |
| Inverse root mean squared error | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : inverse root mean squared error | |
| ''' | |
| return np.sqrt(np.mean(((1.0 / tgt) - (1.0 / src)) ** 2)) | |
| def inv_mean_abs_err(src, tgt): | |
| ''' | |
| Inverse mean absolute error | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : inverse mean absolute error | |
| ''' | |
| return np.mean(np.abs((1.0 / tgt) - (1.0 / src))) | |
| def mean_abs_rel_err(src, tgt): | |
| ''' | |
| Mean absolute relative error (normalize absolute error) | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : mean absolute relative error between source and target | |
| ''' | |
| return np.mean(np.abs(src - tgt) / tgt) | |
| def mean_sq_rel_err(src, tgt): | |
| ''' | |
| Mean squared relative error (normalize squared error) | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| Returns: | |
| float : mean squared relative error between source and target | |
| ''' | |
| return np.mean(((src - tgt) ** 2) / tgt) | |
| def thr_acc(src, tgt, thr=1.25): | |
| ''' | |
| Threshold accuracy | |
| Arg(s): | |
| src : numpy[float32] | |
| source array | |
| tgt : numpy[float32] | |
| target array | |
| thr : float | |
| threshold | |
| Returns: | |
| float : threshold accuracy | |
| ''' | |
| return np.mean(np.maximum((tgt / src), (src / tgt)) < thr) | |