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
File size: 2,372 Bytes
f348660 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | """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)
|