multimodalart's picture
multimodalart HF Staff
Upload folder using huggingface_hub
cbbf804 verified
Raw
History Blame Contribute Delete
644 Bytes
# Minimal shim: taming.models.{vqgan,cond_transformer} do `from main import instantiate_from_config`.
# We vendor only these two helpers to avoid the full training script's heavy deps.
import importlib
def get_obj_from_str(string, reload=False):
module, cls = string.rsplit(".", 1)
if reload:
importlib.reload(importlib.import_module(module))
return getattr(importlib.import_module(module, package=None), cls)
def instantiate_from_config(config):
if "target" not in config:
raise KeyError("Expected key `target` to instantiate.")
return get_obj_from_str(config["target"])(**config.get("params", dict()))