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 os | |
| class Log: | |
| log_on = True | |
| used_tags = dict() # To keep track of used tags | |
| _is_main_cached = None # Cache to store the main process check result | |
| def is_main_process(): | |
| if Log._is_main_cached is not None: | |
| return Log._is_main_cached | |
| try: | |
| from pytorch_lightning.utilities import rank_zero_only | |
| if rank_zero_only.rank == 0: | |
| Log._is_main_cached = True | |
| else: | |
| Log._is_main_cached = False | |
| except: | |
| Log._is_main_cached = True | |
| return Log._is_main_cached | |
| def _should_log(tag): | |
| if not Log.log_on: | |
| return False | |
| if not Log.is_main_process(): | |
| return False | |
| if tag is None: | |
| return True | |
| if '__' in tag: | |
| num = int(tag.split('__')[-1]) | |
| tag = tag.split('__')[0] | |
| else: | |
| num = 3 | |
| if tag not in Log.used_tags: | |
| Log.used_tags[tag] = num | |
| Log.used_tags[tag] -= 1 | |
| if Log.used_tags[tag] >= 0: | |
| return True | |
| else: | |
| return False | |
| def info(*args, tag=None): | |
| if Log._should_log(tag): | |
| print("\033[1;32m[INFO]\033[0;0m", *args) | |
| def warn(*args, tag=None): | |
| if Log._should_log(tag): | |
| print("\033[1;35m[WARN]\033[0;0m", *args) | |
| def error(*args, tag=None): | |
| print("\033[1;31m[ERROR]\033[0;0m", *args) | |
| def debug(*args, tag=None): | |
| if Log._should_log(tag) and 'HT_DEBUG' in os.environ and os.environ['HT_DEBUG'] == '1': | |
| print("\033[1;33m[DEBUG]\033[0;0m", *args) | |
| def monitor_process_wrapper(func): | |
| """The wrapper will print a log both before and after the wrapped function runned.""" | |
| def wrapped(*args, **kwargs): | |
| Log.info(f'"{func.__name__}()" begin...') | |
| ret_value = func(*args, **kwargs) | |
| Log.info(f'"{func.__name__}()" end...') | |
| return ret_value | |
| return wrapped | |
| def monitor_class_process_wrapper(func): | |
| """The wrapper will print a log both before and after the wrapped function runned.""" | |
| def wrapped(self, *args, **kwargs): | |
| Log.info(f'"{self.__class__.__name__}.{func.__name__}()" begin...') | |
| ret_value = func(self, *args, **kwargs) | |
| Log.info(f'"{self.__class__.__name__}.{func.__name__}()" end...') | |
| return ret_value | |
| return wrapped | |