MCPcopy Create free account
hub / github.com/DragonisCV/RAM / define_model

Function define_model

inference/inference.py:12–35  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

10from ram.archs.swinir_arch import SwinIR
11import os.path as osp
12def define_model(args):
13 if args.model =="ram_promptir":
14 model = PromptIR(decoder=True)
15 elif args.model == 'ram_swinir':
16 model = SwinIR(
17 patch_size = 1,
18 in_chans = 3,
19 embed_dim = 180,
20 depths = [ 6, 6, 6, 6, 6, 6],
21 num_heads = [ 6, 6, 6, 6, 6, 6 ],
22 mlp_ratio = 2,
23 window_size = 8,
24 finetune_type = None,
25 upscale = 1
26 )
27 else:
28 raise NotImplementedError
29 loadnet = torch.load(args.model_path)
30 if 'params_ema' in loadnet:
31 keyname = 'params_ema'
32 else:
33 keyname = 'params'
34 model.load_state_dict(loadnet[keyname], strict=False)
35 return model
36
37def process_image(img_path, model, device, args):
38 imgname = osp.splitext(osp.basename(img_path))[0]

Callers 1

mainFunction · 0.85

Calls 2

PromptIRClass · 0.90
SwinIRClass · 0.90

Tested by

no test coverage detected