Skip to content

Instantly share code, notes, and snippets.

closest translated filtered
0 ('ideal', 0.8098761439323425) ('awful', 0.6842296123504639) ('awful', 0.6842296123504639)
1 ('great', 0.7407215237617493) ('terrible', 0.6696542501449585) ('terrible', 0.6696542501449585)
2 ('perfectly', 0.737203061580658) ('bad', 0.662799596786499) ('bad', 0.662799596786499)
3 ('good', 0.729468822479248) ('horrible', 0.6594321727752686) ('horrible', 0.6594321727752686)
4 ('wonderful', 0.7194229364395142) ('ugly', 0.6511248350143433) ('ugly', 0.6511248350143433)
5 ('excellent', 0.7181068658828735) ('ideal', 0.6327192187309265) ('thing', 0.6208710670471191)
6 ('beautiful', 0.7177813649177551) ('thing', 0.6208710670471191) ('kind', 0.6105346083641052)
7 ('fantastic', 0.7143319845199585) ('kind', 0.6105346083641052) ('worst', 0.609749436378479)
8 ('nice', 0.7134328484535217) ('worst', 0.609749436378479)
@mboyanov
mboyanov / alpha_copy.py
Created January 30, 2018 18:02
Utility to copy the alpha channel from a 4d numpy image to a 3d numpy image
def copy_alpha(source, target):
new_shape = np.copy(target.shape)
new_shape[2] = 4
fourd = np.zeros(new_shape, dtype=np.uint8)
fourd[:, :, 3] = source[:, :, 3] # copy the alpha channel
fourd[:, :, :3] = target[:, :, :3] #copy the content
return fourd