MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / code2img

Function code2img

SwissArmyTransformer/sat/tokenization/cogview/vqvae/api.py:225–237  ·  view source on GitHub ↗

Convert a batch of code to imgs Args: model: ... code: [b, h, w] or [b, h*w] LongTensor

(model, code)

Source from the content-addressed store, hash-verified

223 return id_t1.view(img.shape[0], -1)
224
225def code2img(model, code):
226 '''Convert a batch of code to imgs
227 Args:
228 model: ...
229 code: [b, h, w] or [b, h*w] LongTensor
230 '''
231 if len(code.shape) == 2:
232 s = int(math.sqrt(len(code.view(-1))) + 1e-5)
233 code = code.view(code.shape[0], s, s)
234 with torch.no_grad():
235 out = model.decode_code(code)
236 out = out * torch.tensor([0.30379, 0.32279, 0.32800], device=out.device).view(1, -1, 1, 1) + torch.tensor([0.79093, 0.76271, 0.75340], device=out.device).view(1, -1, 1, 1)
237 return out
238

Callers 1

DecodeIdsMethod · 0.85

Calls 1

decode_codeMethod · 0.80

Tested by

no test coverage detected