-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_generator.py
49 lines (45 loc) · 1.72 KB
/
data_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
from datetime import datetime
from pprint import pprint
import json
emotions = {
"happy": 0,
"sad": 0,
"fear": 0,
"angry": 0,
"disgust": 0,
"surprise": 0,
"neutral": 0
}
data = {}
timestamp = 1566998321
count = 100
for i in range(1, count):
arr = np.array([i, # less prob
count - i, # high prob
np.random.randint(2, size=1),
np.random.randint(2, size=1),
np.random.randint(2, size=1),
np.random.randint(2, size=1),
np.random.randint(2, size=1)])
arr = arr/sum(arr)
emotions = {}
emotions["happy"] = float(arr[0]) # less prob
emotions["neutral"] = float(arr[1]) # high prob
emotions["fear"] = float(arr[2])
emotions["surprise"] = float(arr[3])
emotions["sad"] = float(arr[4])
emotions["disgust"] = float(arr[5])
emotions["angry"] = float(arr[6])
#pprint(emotions)
data[str(datetime.fromtimestamp(timestamp))] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"]["face"] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"]["text"] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"]["face"]["emotions"] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"]["text"]["emotions"] = {}
data[str(datetime.fromtimestamp(timestamp))]["person"]["face"]["emotions"] = emotions
data[str(datetime.fromtimestamp(timestamp))]["person"]["text"]["emotions"] = emotions
timestamp += 1
with open("scenario_neutral_happy.json", "w") as file:
json.dump(data, file)