INNER CODE UNIT · Python
SOS
dailenson/SDT · user_generate.py:54
SOS = torch.tensor(bs * [[0, 0, 1, 0, 0]]).unsqueeze(1).to(preds)
preds = torch.cat((SOS, preds), 1) # add the SOS token like GT
preds = preds.detach().cpu().numpy()
for i, pred in enumerate(preds):
"""Render the character images by connecting the coordinates"""
sk_pil = coords_render(preds[i], split=True, width=256, height=256, thickness=8, board=1)
save_path = os.path.join(opt.save_dir, char[i] +'.png')
try:
sk_pil.save(save_path)
except:
print('error. %s, %s' % (save_path, char[i]))
if __name__ == '__main__':
"""Parse input arguments"""
parser = argparse.ArgumentParser()