MCPcopy Create free account
hub / github.com/NVIDIA/vid2vid / wrap_model

Function wrap_model

models/models.py:10–24  ·  view source on GitHub ↗
(opt, modelG, modelD, flowNet)

Source from the content-addressed store, hash-verified

8def lcm(a,b): return abs(a * b)/fractions.gcd(a,b) if a and b else 0
9
10def wrap_model(opt, modelG, modelD, flowNet):
11 if opt.n_gpus_gen == len(opt.gpu_ids):
12 modelG = myModel(opt, modelG)
13 modelD = myModel(opt, modelD)
14 flowNet = myModel(opt, flowNet)
15 else:
16 if opt.batchSize == 1:
17 gpu_split_id = opt.n_gpus_gen + 1
18 modelG = nn.DataParallel(modelG, device_ids=opt.gpu_ids[0:1])
19 else:
20 gpu_split_id = opt.n_gpus_gen
21 modelG = nn.DataParallel(modelG, device_ids=opt.gpu_ids[:gpu_split_id])
22 modelD = nn.DataParallel(modelD, device_ids=[opt.gpu_ids[0]] + opt.gpu_ids[gpu_split_id:])
23 flowNet = nn.DataParallel(flowNet, device_ids=[opt.gpu_ids[0]] + opt.gpu_ids[gpu_split_id:])
24 return modelG, modelD, flowNet
25
26class myModel(nn.Module):
27 def __init__(self, opt, model):

Callers 2

create_modelFunction · 0.85
create_optimizerFunction · 0.85

Calls 1

myModelClass · 0.85

Tested by

no test coverage detected