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

Function img2code

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

Convert a batch of img to code Args: model: The tokenizer model. img: [b, c, h, w]

(model, img)

Source from the content-addressed store, hash-verified

213 )
214
215def img2code(model, img):
216 '''Convert a batch of img to code
217 Args:
218 model: The tokenizer model.
219 img: [b, c, h, w]
220 '''
221 with torch.no_grad():
222 quant_t1, _, id_t1 = model.encode(img)
223 return id_t1.view(img.shape[0], -1)
224
225def code2img(model, code):
226 '''Convert a batch of code to imgs

Callers 1

EncodeAsIdsMethod · 0.85

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected