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 11
11
from pytorch_lightning .callbacks import ModelCheckpoint , Callback , LearningRateMonitor
12
12
from pytorch_lightning .utilities import rank_zero_only
13
13
14
+ from taming import get_obj_from_str , instantiate_from_config
14
15
from taming .data .utils import custom_collate
15
16
16
17
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
-
25
18
def get_parser (** parser_kwargs ):
26
19
def str2bool (v ):
27
20
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 3
3
import torch .nn .functional as F
4
4
import pytorch_lightning as pl
5
5
6
- from main import instantiate_from_config
6
+ from taming import instantiate_from_config
7
7
from taming .modules .util import SOSProvider
8
8
9
9
Original file line number Diff line number Diff line change 2
2
import torch .nn .functional as F
3
3
import pytorch_lightning as pl
4
4
5
- from main import instantiate_from_config
5
+ from taming import instantiate_from_config
6
6
7
7
from taming .modules .diffusionmodules .model import Encoder , Decoder
8
8
from taming .modules .vqvae .quantize import VectorQuantizer2 as VectorQuantizer
You can’t perform that action at this time.
0 commit comments