File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 1111from pytorch_lightning .callbacks import ModelCheckpoint , Callback , LearningRateMonitor
1212from pytorch_lightning .utilities import rank_zero_only
1313
14+ from taming import get_obj_from_str , instantiate_from_config
1415from taming .data .utils import custom_collate
1516
1617
17- def get_obj_from_str (string , reload = False ):
18- module , cls = string .rsplit ("." , 1 )
19- if reload :
20- module_imp = importlib .import_module (module )
21- importlib .reload (module_imp )
22- return getattr (importlib .import_module (module , package = None ), cls )
23-
24-
2518def get_parser (** parser_kwargs ):
2619 def str2bool (v ):
2720 if isinstance (v , bool ):
Original file line number Diff line number Diff line change 1+ import importlib
2+
3+ def get_obj_from_str (string , reload = False ):
4+ module , cls = string .rsplit ("." , 1 )
5+ if reload :
6+ module_imp = importlib .import_module (module )
7+ importlib .reload (module_imp )
8+ return getattr (importlib .import_module (module , package = None ), cls )
9+
10+ def instantiate_from_config (config ):
11+ if not "target" in config :
12+ raise KeyError ("Expected key `target` to instantiate." )
13+ return get_obj_from_str (config ["target" ])(** config .get ("params" , dict ()))
Original file line number Diff line number Diff line change 33import torch .nn .functional as F
44import pytorch_lightning as pl
55
6- from main import instantiate_from_config
6+ from taming import instantiate_from_config
77from taming .modules .util import SOSProvider
88
99
Original file line number Diff line number Diff line change 22import torch .nn .functional as F
33import pytorch_lightning as pl
44
5- from main import instantiate_from_config
5+ from taming import instantiate_from_config
66
77from taming .modules .diffusionmodules .model import Encoder , Decoder
88from taming .modules .vqvae .quantize import VectorQuantizer2 as VectorQuantizer
You can’t perform that action at this time.
0 commit comments