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
File size: 1,479 Bytes
d547008 | 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 | from pathlib import Path
from datetime import datetime
import shortuuid
from omegaconf import DictConfig
def flatten_dict_cfg(cfg): # [dict | DictConfig]) -> DictConfig:
ret = {}
if isinstance(cfg, dict):
cfg = DictConfig(cfg)
for k, v in cfg.items():
if isinstance(v, DictConfig):
ret_v = flatten_dict_cfg(v)
for _k, _v in ret_v.items():
ret[f'{k}_{_k}'] = _v
else:
ret[k] = v
return DictConfig(ret)
def current_time():
current_time = datetime.now()
readable_time = current_time.strftime("%Y-%m-%d-%H:%M:%S")
return readable_time
def uuid(length=8):
"""
https://github.com/wandb/client/blob/master/wandb/util.py#L677
"""
# ~3t run ids (36**8)
run_gen = shortuuid.ShortUUID(alphabet=list("0123456789abcdefghijklmnopqrstuvwxyz"))
return run_gen.random(length)
def pathlib_file(file_name):
if isinstance(file_name, str):
file_name = Path(file_name)
elif not isinstance(file_name, Path):
raise TypeError(f'Please check the type of the filename:{file_name}')
return file_name
def assign_item_to_dict(d: dict, ks: list, v):
'''
run d[ks[0]][ks[1]]...[ks[-1]] = v with filling empty keys
:param d:
:param ks:
:param v:
:return:
'''
k = ks[0]
if len(ks) == 1:
d[k] = v
else:
if k not in d:
d[k] = dict()
assign_item_to_dict(d[k], ks[1:], v)
|