MCPcopy Index your code
hub / github.com/OpenGVLab/DragGAN / on_change_model

Function on_change_model

draggan/deprecated/web.py:131–146  ·  view source on GitHub ↗
(selected, model)

Source from the content-addressed store, hash-verified

129
130
131def on_change_model(selected, model):
132 size = CKPT_SIZE[selected]
133 model = ModelWrapper(size=size, ckpt=selected)
134 g_ema = model.g_ema
135 sample_z = torch.randn([1, 512], device=device)
136 latent, noise = g_ema.prepare([sample_z])
137 sample, F = g_ema.generate(latent, noise)
138
139 state = {
140 'latent': latent,
141 'noise': noise,
142 'F': F,
143 'sample': sample,
144 'history': []
145 }
146 return model, state, to_image(sample), to_image(sample), size
147
148
149def on_new_image(model):

Callers

nothing calls this directly

Calls 4

ModelWrapperClass · 0.85
prepareMethod · 0.80
generateMethod · 0.80
to_imageFunction · 0.70

Tested by

no test coverage detected