import sys from .model_utils import get_block # sys.path.append('../../../lungNoduleDensityClassification/nodulecls/utils') # from RWconfig import LoadJson import os # os.environ["CUDA_VISIBLE_DEVICES"]="2" import torch # from torchsummary import summary def build_model(model_name,cfg): func = get_block(model_name) if "ResNet" in model_name : cfg['block'] = get_block(cfg['block']) return func(model_params=cfg) # if __name__ == "__main__": # cfg_path = '../files/modelParams/model_parameters.json' # model_cfgs = LoadJson(cfg_path) # model_name = "NoduleSegDecoder_proxima" # cfg = model_cfgs[model_name] # if "encoder_model_name" in cfg.keys(): # encoder_model_name = "XnetEncoder" # encoder_cfg = model_cfgs[encoder_model_name] # encoder = build_model(encoder_model_name,encoder_cfg) # cfg['encoder_model'] = encoder # model = build_model(model_name,cfg) # else: # model = build_model(model_name,cfg) # print ('cfg is ',cfg) # summary(model.cuda(),(1,32,96,96)) # total_params = sum(p.numel() for p in model.parameters()) # print(f'{total_params:,} total parameters.') # # summary(model,(1,24,24,24),device='cpu')