Skip to content

Commit a9eaaea

Browse files
Add New Shapes
tongue go brr
1 parent 2baf74f commit a9eaaea

File tree

2 files changed

+153
-115
lines changed

2 files changed

+153
-115
lines changed

BabbleCPU.py

Lines changed: 69 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ def _load_calibration(self, filename):
5757
self.calib = json.load(user_file)
5858
self._last_update = os.fstat(user_file.fileno()).st_mtime
5959
self.jsonminmax = [
60-
[self.calib["cheekPuff"]["min"],self.calib["cheekPuff"]["max"]], # CheekPuff
61-
[self.calib["noseSneerLeft"]["min"],self.calib["noseSneerLeft"]["max"]], # noseSneerLeft
62-
[self.calib["noseSneerRight"]["min"],self.calib["noseSneerRight"]["max"]], # noseSneerRight
60+
[self.calib["cheekPuffLeft"]["min"],self.calib["cheekPuffLeft"]["max"]], # CheekPuff
61+
[self.calib["cheekPuffRight"]["min"],self.calib["cheekPuffRight"]["max"]], # CheekPuff
62+
[self.calib["cheekSuckLeft"]["min"],self.calib["cheekSuckLeft"]["max"]], # CheekPuff
63+
[self.calib["cheekSuckRight"]["min"],self.calib["cheekSuckRight"]["max"]], # CheekPuff
6364
[self.calib["jawOpen"]["min"],self.calib["jawOpen"]["max"]], # jawOpen
6465
[self.calib["jawForward"]["min"],self.calib["jawForward"]["max"]], # jawForward
6566
[self.calib["jawLeft"]["min"],self.calib["jawLeft"]["max"]], # jawLeft
6667
[self.calib["jawRight"]["min"],self.calib["jawRight"]["max"]], # jawRight
68+
[self.calib["noseSneerLeft"]["min"],self.calib["noseSneerLeft"]["max"]], # noseSneerLeft
69+
[self.calib["noseSneerRight"]["min"],self.calib["noseSneerRight"]["max"]], # noseSneerRight
6770
[self.calib["mouthFunnel"]["min"],self.calib["mouthFunnel"]["max"]], # mouthFunnel
6871
[self.calib["mouthPucker"]["min"],self.calib["mouthPucker"]["max"]], # mouthPucker
6972
[self.calib["mouthLeft"]["min"],self.calib["mouthLeft"]["max"]], # mouthLeft
@@ -88,49 +91,20 @@ def _load_calibration(self, filename):
8891
[self.calib["mouthStretchLeft"]["min"],self.calib["mouthStretchLeft"]["max"]], # mouthStretchLeft
8992
[self.calib["mouthStretchRight"]["min"],self.calib["mouthStretchRight"]["max"]], # mouthStretchRight
9093
[self.calib["tongueOut"]["min"],self.calib["tongueOut"]["max"]], # tongueOut
94+
[self.calib["tongueUp"]["min"],self.calib["tongueUp"]["max"]], # tongueOut
95+
[self.calib["tongueDown"]["min"],self.calib["tongueDown"]["max"]], # tongueOut
96+
[self.calib["tongueLeft"]["min"],self.calib["tongueLeft"]["max"]], # tongueOut
97+
[self.calib["tongueRight"]["min"],self.calib["tongueRight"]["max"]], # tongueOut
98+
[self.calib["tongueRoll"]["min"],self.calib["tongueRoll"]["max"]], # tongueOut
99+
[self.calib["tongueBendDown"]["min"],self.calib["tongueBendDown"]["max"]], # tongueOut
100+
[self.calib["tongueCurlUp"]["min"],self.calib["tongueCurlUp"]["max"]], # tongueOut
101+
[self.calib["tongueSquish"]["min"],self.calib["tongueSquish"]["max"]], # tongueOut
102+
[self.calib["tongueFlat"]["min"],self.calib["tongueFlat"]["max"]], # tongueOut
103+
[self.calib["tongueTwistLeft"]["min"],self.calib["tongueTwistLeft"]["max"]], # tongueOut
104+
[self.calib["tongueTwistRight"]["min"],self.calib["tongueTwistRight"]["max"]], # tongueOut
91105
]
92106
return self.jsonminmax
93107

94-
95-
def onesizefitsallminmaxarray(): # Some predefined ranges in stored values instead of the generated ones
96-
stored_values = [
97-
[0.2, 0.6], # CheekPuff
98-
[0, 1], # cheekSquintLeft
99-
[0, 1], # cheekSquintRight
100-
[0, 1], # noseSneerLeft
101-
[0, 1], # noseSneerRight
102-
[0.03, 0.6], # jawOpen
103-
[0.1, 0.8], # jawForward
104-
[0.05, 0.5], # jawLeft
105-
[0.05, 0.5], # jawRight
106-
[0.1, 0.6], # mouthFunnel
107-
[0.4, 1], # mouthPucker
108-
[0.05, 0.5], # mouthLeft
109-
[0.05, 0.5], # mouthRight
110-
[0, 0.5], # mouthRollUpper
111-
[0, 0.3], # mouthRollLower
112-
[0.03, 0.5], # mouthShrugUpper
113-
[0.03, 0.5], # mouthShrugLower
114-
[0, 0.5], # mouthClose
115-
[0.1, 1], # mouthSmileLeft
116-
[0.1, 1], # mouthSmileRight
117-
[0, 0.6], # mouthFrownLeft
118-
[0, 0.6], # mouthFrownRight
119-
[0, 1], # mouthDimpleLeft
120-
[0, 1], # mouthDimpleRight
121-
[0.02, 0.8], # mouthUpperUpLeft
122-
[0.02, 0.8], # mouthUpperUpRight
123-
[0.02, 0.8], # mouthLowerDownLeft
124-
[0.02, 0.8], # mouthLowerDownRight
125-
[0, 1], # mouthPressLeft
126-
[0, 1], # mouthPressRight
127-
[0.3, 1], # mouthStretchLeft
128-
[0.3, 1], # mouthStretchRight
129-
[0.2, 0.8], # tongueOut
130-
]
131-
return stored_values
132-
133-
134108

135109
def makeminmaxarray(amount):
136110
stored_values = []
@@ -168,11 +142,11 @@ def normalize_value(array):
168142
layout = [
169143
[sg.Image(key = '-IMAGE-')],
170144
[sg.Text('Enter Webcam URL or Number (Defualts to 0)'), sg.Input(key = '-URL-', size = (30, 1))],
171-
[sg.Text('Enter Onnx model name (Defualts to EffnetB0300K.onnx)'), sg.Input(key = '-MODEL-', size = (30, 1))],
145+
[sg.Text('Enter Onnx model name (Defualts to EFV2300K45E57.onnx)'), sg.Input(key = '-MODEL-', size = (30, 1))],
172146
[sg.Text('OSC Location Address'), sg.Input(key = '-LOC-', size = (30, 1))],
173147
[sg.Text('Output Mutiplier (defualts to 1. Please use 100 if you are using the unity demo.)'), sg.Input(key = '-MULT-', size = (30, 1))],
174148
[sg.Text('Enter OSC IP (Defualts to 127.0.0.1)'), sg.Input(key = '-OSC-', size = (30, 1))],
175-
[sg.Text('Enter OSC Port (Defualts to 9000)'), sg.Input(key = '-PORT-', size = (30, 1))],
149+
[sg.Text('Enter OSC Port (Defualts to 8888)'), sg.Input(key = '-PORT-', size = (30, 1))],
176150
[sg.Text('Enter Calibration file name (Defaults to calib.json)'), sg.Input(key = '-JSON_FILE-', size = (30, 1))],
177151
[sg.Text('Press Ok to start the webcam')],
178152
[sg.Checkbox('Flip 180', key = '-FLIP180-')],
@@ -199,7 +173,9 @@ def normalize_value(array):
199173
OSCip="127.0.0.1"
200174
OSCport= values['-PORT-'] #VR Chat OSC port
201175
if OSCport == '':
202-
OSCport = 9000
176+
OSCport = 8888
177+
else:
178+
OSCport = int(OSCport)
203179
multi = values['-MULT-']
204180
if multi == '':
205181
multi = 1
@@ -208,7 +184,7 @@ def normalize_value(array):
208184
client = udp_client.SimpleUDPClient(OSCip, OSCport)
209185
model = values['-MODEL-']
210186
if model == '':
211-
model = 'EffnetB0300K.onnx'
187+
model = 'EFV2300K45E57.onnx'
212188
if calibjson == '':
213189
calibjson = 'calib.json'
214190
usegpu = values['-GPU-']
@@ -254,6 +230,7 @@ def normalize_value(array):
254230
if flip90r:
255231
frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE)
256232
frame2 = frame
233+
#frame = cv2.flip(frame, 1)
257234
calibration.update_calib(calibjson) # Checks and updates values of the json file
258235
stored_values = calibration.jsonminmax
259236
frame = cv2.resize(frame, (256, 256))
@@ -282,37 +259,51 @@ def normalize_value(array):
282259
array = output
283260
for i in range(len(output)): # Clip values between 0 - 1
284261
output[i] = max(min(output[i], 1), 0)
285-
client.send_message(location + "/cheekPuff", array[0] * multi)
286-
client.send_message(location + "/noseSneerLeft", output[5] * multi)
287-
client.send_message(location + "/noseSneerRight", output[6] * multi)
288-
client.send_message(location + "/jawOpen", array[1] * multi)
289-
client.send_message(location + "/jawForward", array[2] * multi)
290-
client.send_message(location + "/jawLeft", array[3] * multi)
291-
client.send_message(location + "/jawRight", array[4] * multi)
292-
client.send_message(location + "/mouthFunnel", array[7] * multi)
293-
client.send_message(location + "/mouthPucker", array[8] * multi)
294-
client.send_message(location + "/mouthLeft", array[9] * multi)
295-
client.send_message(location + "/mouthRight", array[10] * multi)
296-
client.send_message(location + "/mouthRollUpper", array[11] * multi)
297-
client.send_message(location + "/mouthRollLower", array[12] * multi)
298-
client.send_message(location + "/mouthShrugUpper", array[13] * multi)
299-
client.send_message(location + "/mouthShrugLower", array[14] * multi)
300-
client.send_message(location + "/mouthClose", output[15] * multi)
301-
client.send_message(location + "/mouthSmileLeft", array[16] * multi)
302-
client.send_message(location + "/mouthSmileRight", array[17] * multi)
303-
client.send_message(location + "/mouthFrownLeft", array[18] * multi)
304-
client.send_message(location + "/mouthFrownRight", array[19] * multi)
305-
client.send_message(location + "/mouthDimpleLeft", array[20] * multi)
306-
client.send_message(location + "/mouthDimpleRight", array[21] * multi)
307-
client.send_message(location + "/mouthUpperUpLeft", array[22] * multi)
308-
client.send_message(location + "/mouthUpperUpRight", array[23] * multi)
309-
client.send_message(location + "/mouthLowerDownLeft", array[24] * multi)
310-
client.send_message(location + "/mouthLowerDownRight", array[25] * multi)
311-
client.send_message(location + "/mouthPressLeft", array[26] * multi)
312-
client.send_message(location + "/mouthPressRight", array[27] * multi)
313-
client.send_message(location + "/mouthStretchLeft", array[28] * multi)
314-
client.send_message(location + "/mouthStretchRight", array[29] * multi)
315-
client.send_message(location + "/tongueOut", array[30] * multi)
262+
client.send_message(location + "/cheekPuffLeft", array[0] * multi)
263+
client.send_message(location + "/cheekPuffRight", array[1] * multi)
264+
client.send_message(location + "/cheekSuckLeft", array[2] * multi)
265+
client.send_message(location + "/cheekSuckRight", array[3] * multi)
266+
client.send_message(location + "/jawOpen", array[4] * multi)
267+
client.send_message(location + "/jawForward", array[5] * multi)
268+
client.send_message(location + "/jawLeft", array[6] * multi)
269+
client.send_message(location + "/jawRight", array[7] * multi)
270+
client.send_message(location + "/noseSneerLeft", array[8] * multi)
271+
client.send_message(location + "/noseSneerRight", array[9] * multi)
272+
client.send_message(location + "/mouthFunnel", array[10] * multi)
273+
client.send_message(location + "/mouthPucker", array[11] * multi)
274+
client.send_message(location + "/mouthLeft", array[12] * multi)
275+
client.send_message(location + "/mouthRight", array[13] * multi)
276+
client.send_message(location + "/mouthRollUpper", array[14] * multi)
277+
client.send_message(location + "/mouthRollLower", array[15] * multi)
278+
client.send_message(location + "/mouthShrugUpper", array[16] * multi)
279+
client.send_message(location + "/mouthShrugLower", array[17] * multi)
280+
client.send_message(location + "/mouthClose", output[18] * multi)
281+
client.send_message(location + "/mouthSmileLeft", array[19] * multi)
282+
client.send_message(location + "/mouthSmileRight", array[20] * multi)
283+
client.send_message(location + "/mouthFrownLeft", array[21] * multi)
284+
client.send_message(location + "/mouthFrownRight", array[22] * multi)
285+
client.send_message(location + "/mouthDimpleLeft", array[23] * multi)
286+
client.send_message(location + "/mouthDimpleRight", array[24] * multi)
287+
client.send_message(location + "/mouthUpperUpLeft", array[25] * multi)
288+
client.send_message(location + "/mouthUpperUpRight", array[26] * multi)
289+
client.send_message(location + "/mouthLowerDownLeft", array[27] * multi)
290+
client.send_message(location + "/mouthLowerDownRight", array[28] * multi)
291+
client.send_message(location + "/mouthPressLeft", array[29] * multi)
292+
client.send_message(location + "/mouthPressRight", array[30] * multi)
293+
client.send_message(location + "/mouthStretchLeft", array[31] * multi)
294+
client.send_message(location + "/mouthStretchRight", array[32] * multi)
295+
client.send_message(location + "/tongueOut", array[33] * multi)
296+
client.send_message(location + "/tongueUp", array[34] * multi)
297+
client.send_message(location + "/tongueDown", array[35] * multi)
298+
client.send_message(location + "/tongueLeft", array[36] * multi)
299+
client.send_message(location + "/tongueRight", array[37] * multi)
300+
client.send_message(location + "/tongueRoll", array[38] * multi)
301+
client.send_message(location + "/tongueBendDown", array[39] * multi)
302+
client.send_message(location + "/tongueCurlUp", array[40] * multi)
303+
client.send_message(location + "/tongueSquish", array[41] * multi)
304+
client.send_message(location + "/tongueFlat", array[42] * multi)
305+
client.send_message(location + "/tongueTwistLeft", array[43] * multi)
306+
client.send_message(location + "/tongueTwistRight", array[44] * multi)
316307
frame2 = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
317308
imgbytes = cv2.imencode('.png', frame2)[1].tobytes() # ditto
318309
window['-IMAGE-'].update(data=imgbytes)

calib.json

Lines changed: 84 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,79 @@
11
{
2-
"cheekPuff": {
3-
"min": 0.0,
4-
"max": 0.5
5-
},
6-
"cheekSquintLeft": {
7-
"min": 0.0,
2+
"cheekPuffLeft": {
3+
"min": 0.1,
84
"max": 1.0
95
},
10-
"cheekSquintRight": {
11-
"min": 0.0,
6+
"cheekPuffRight": {
7+
"min": 0.1,
128
"max": 1.0
139
},
14-
"noseSneerLeft": {
15-
"min": 0.0,
10+
"cheekSuckLeft": {
11+
"min": 0.1,
1612
"max": 1.0
1713
},
18-
"noseSneerRight": {
19-
"min": 0.0,
14+
"cheekSuckRight": {
15+
"min": 0.1,
2016
"max": 1.0
2117
},
2218
"jawOpen": {
23-
"min": 0.0,
24-
"max": 0.7
19+
"min": 0.0,
20+
"max": 1.0
2521
},
2622
"jawForward": {
27-
"min": 0.1,
28-
"max": 0.8
23+
"min": 0.0,
24+
"max": 1.0
2925
},
3026
"jawLeft": {
3127
"min": 0.0,
32-
"max": 0.5
28+
"max": 1.0
3329
},
3430
"jawRight": {
3531
"min": 0.0,
36-
"max": 0.5
32+
"max": 1.0
33+
},
34+
"noseSneerLeft": {
35+
"min": 0.0,
36+
"max": 1.0
37+
},
38+
"noseSneerRight": {
39+
"min": 0.0,
40+
"max": 1.0
3741
},
3842
"mouthFunnel": {
3943
"min": 0.05,
40-
"max": 0.8
44+
"max": 1.0
4145
},
4246
"mouthPucker": {
4347
"min": 0.0,
44-
"max": 0.8
48+
"max": 1.0
4549
},
4650
"mouthLeft": {
4751
"min": 0.05,
48-
"max": 0.7
52+
"max": 1.0
4953
},
5054
"mouthRight": {
5155
"min": 0.05,
52-
"max": 0.7
56+
"max": 1.0
5357
},
5458
"mouthRollUpper": {
5559
"min": 0.0,
56-
"max": 0.7
60+
"max": 1.0
5761
},
5862
"mouthRollLower": {
5963
"min": 0.0,
60-
"max": 0.7
64+
"max": 1.0
6165
},
6266
"mouthShrugUpper": {
63-
"min": 0.03,
64-
"max": 0.6
67+
"min": 0.0,
68+
"max": 1.0
6569
},
6670
"mouthShrugLower": {
67-
"min": 0.03,
68-
"max": 0.6
71+
"min": 0.0,
72+
"max": 1.0
6973
},
7074
"mouthClose": {
71-
"min": 0.2,
72-
"max": 0.7
75+
"min": 0.0,
76+
"max": 1.0
7377
},
7478
"mouthSmileLeft": {
7579
"min": 0.0,
@@ -81,11 +85,11 @@
8185
},
8286
"mouthFrownLeft": {
8387
"min": 0.0,
84-
"max": 0.7
88+
"max": 1.0
8589
},
8690
"mouthFrownRight": {
8791
"min": 0.0,
88-
"max": 0.7
92+
"max": 1.0
8993
},
9094
"mouthDimpleLeft": {
9195
"min": 0.0,
@@ -120,16 +124,59 @@
120124
"max": 1.0
121125
},
122126
"mouthStretchLeft": {
123-
"min": 0.3,
127+
"min": 0.05,
124128
"max": 1.0
125129
},
126130
"mouthStretchRight": {
127-
"min": 0.3,
131+
"min": 0.05,
128132
"max": 1.0
129133
},
130134
"tongueOut": {
131-
"min": 0.2,
132-
"max": 0.8
135+
"min": 0.05,
136+
"max": 1.0
137+
},
138+
"tongueUp": {
139+
"min": 0.05,
140+
"max": 1.0
141+
},
142+
"tongueDown": {
143+
"min": 0.05,
144+
"max": 1.0
145+
},
146+
"tongueLeft": {
147+
"min": 0.05,
148+
"max": 1.0
149+
},
150+
"tongueRight": {
151+
"min": 0.05,
152+
"max": 1.0
153+
},
154+
"tongueRoll": {
155+
"min": 0.05,
156+
"max": 1.0
157+
},
158+
"tongueBendDown": {
159+
"min": 0.05,
160+
"max": 1.0
161+
},
162+
"tongueCurlUp": {
163+
"min": 0.05,
164+
"max": 1.0
165+
},
166+
"tongueSquish": {
167+
"min": 0.05,
168+
"max": 1.0
169+
},
170+
"tongueFlat": {
171+
"min": 0.05,
172+
"max": 1.0
173+
},
174+
"tongueTwistLeft": {
175+
"min": 0.05,
176+
"max": 1.0
177+
},
178+
"tongueTwistRight": {
179+
"min": 0.05,
180+
"max": 1.0
133181
}
134-
135182
}

0 commit comments

Comments
 (0)