MCPcopy Create free account
hub / github.com/albertpumarola/GANimation / plot_au

Function plot_au

utils/plots.py:5–67  ·  view source on GitHub ↗

Plot action units :param img: HxWx3 :param aus: N :return:

(img, aus, title=None)

Source from the content-addressed store, hash-verified

3import matplotlib.pyplot as plt
4
5def plot_au(img, aus, title=None):
6 '''
7 Plot action units
8 :param img: HxWx3
9 :param aus: N
10 :return:
11 '''
12 fig = plt.figure()
13 ax = fig.add_subplot(1, 1, 1)
14 ax.axis('off')
15 fig.subplots_adjust(0, 0, 0.8, 1) # get rid of margins
16
17 # display img
18 ax.imshow(img)
19
20 if len(aus) == 11:
21 au_ids = ['1','2','4','5','6','9','12','17','20','25','26']
22 x = 0.1
23 y = 0.39
24 i = 0
25 for au, id in zip(aus, au_ids):
26 if id == '9':
27 x = 0.5
28 y -= .15
29 i = 0
30 elif id == '12':
31 x = 0.1
32 y -= .15
33 i = 0
34
35 ax.text(x + i * 0.2, y, id, horizontalalignment='center', verticalalignment='center',
36 transform=ax.transAxes, color='r', fontsize=20)
37 ax.text((x-0.001)+i*0.2, y-0.07, au, horizontalalignment='center', verticalalignment='center',
38 transform=ax.transAxes, color='b', fontsize=20)
39 i+=1
40
41 else:
42 au_ids = ['1', '2', '4', '5', '6', '7', '9', '10', '12', '14', '15', '17', '20', '23', '25', '26', '45']
43 x = 0.1
44 y = 0.39
45 i = 0
46 for au, id in zip(aus, au_ids):
47 if id == '9' or id == '20':
48 x = 0.1
49 y -= .15
50 i = 0
51
52 ax.text(x + i * 0.2, y, id, horizontalalignment='center', verticalalignment='center',
53 transform=ax.transAxes, color='r', fontsize=20)
54 ax.text((x-0.001)+i*0.2, y-0.07, au, horizontalalignment='center', verticalalignment='center',
55 transform=ax.transAxes, color='b', fontsize=20)
56 i+=1
57
58 if title is not None:
59 ax.text(0.5, 0.95, title, horizontalalignment='center', verticalalignment='center',
60 transform=ax.transAxes, color='r', fontsize=20)
61
62 fig.canvas.draw()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected