@@ -92,7 +92,7 @@ def detect_dpu_architecture():
92
92
print ("camera" ,input_video ," (" ,frame_width ,"," ,frame_height ,")" )
93
93
94
94
# Open ASL model
95
- #model = load_model('tf2_asl_classifier .h5')
95
+ #model = load_model('tf2_asl_classifier_1 .h5')
96
96
97
97
# Vitis-AI implementation of ASL model
98
98
@@ -161,7 +161,7 @@ def TopK(datain, size, filePath):
161
161
dpu_arch = detect_dpu_architecture ()
162
162
print ('[INFO] Detected DPU architecture : ' ,dpu_arch )
163
163
164
- model_path = './model /' + dpu_arch + '/asl_classifier .xmodel'
164
+ model_path = './model_1 /' + dpu_arch + '/asl_classifier_1 .xmodel'
165
165
print ('[INFO] ASL model : ' ,model_path )
166
166
167
167
# Create DPU runner
@@ -205,6 +205,38 @@ def TopK(datain, size, filePath):
205
205
rt_fps_message = "FPS: {0:.2f}" .format (rt_fps )
206
206
rt_fps_x = int (10 * scale )
207
207
rt_fps_y = int ((frame_height - 10 )* scale )
208
+
209
+ id_to_class = {
210
+ 0 :"A" ,
211
+ 1 :"B" ,
212
+ 2 :"C" ,
213
+ 3 :"D" ,
214
+ 4 :"E" ,
215
+ 5 :"F" ,
216
+ 6 :"G" ,
217
+ 7 :"H" ,
218
+ 8 :"I" ,
219
+ 9 :"J" ,
220
+ 10 :"K" ,
221
+ 11 :"L" ,
222
+ 12 :"M" ,
223
+ 13 :"N" ,
224
+ 14 :"O" ,
225
+ 15 :"P" ,
226
+ 16 :"Q" ,
227
+ 17 :"R" ,
228
+ 18 :"S" ,
229
+ 19 :"T" ,
230
+ 20 :"U" ,
231
+ 21 :"V" ,
232
+ 22 :"W" ,
233
+ 23 :"X" ,
234
+ 24 :"Y" ,
235
+ 25 :"Z" ,
236
+ 26 :"{del}" ,
237
+ 27 :"{nothing}" ,
238
+ 28 :"{space}"
239
+ }
208
240
209
241
while True :
210
242
# init the real-time FPS counter
@@ -239,36 +271,38 @@ def TopK(datain, size, filePath):
239
271
#asl_y = model.predict(asl_x)
240
272
241
273
""" Prepare input/output buffers """
242
- print ("[INFO] ASL - prep input buffer " )
274
+ # print("[INFO] ASL - prep input buffer ")
243
275
inputData = []
244
276
inputData .append (np .empty ((inputShape ),dtype = np .int8 ,order = 'C' ))
245
277
inputImage = inputData [0 ]
246
278
inputImage [0 ,...] = asl_img
247
279
248
- print ("[INFO] ASL - prep output buffer " )
280
+ # print("[INFO] ASL - prep output buffer ")
249
281
outputData = []
250
282
outputData .append (np .empty ((outputShape ),dtype = np .int8 ,order = 'C' ))
251
283
252
284
""" Execute model on DPU """
253
- print ("[INFO] ASL - execute " )
285
+ # print("[INFO] ASL - execute ")
254
286
job_id = dpu .execute_async ( inputData , outputData )
255
287
dpu .wait (job_id )
256
288
257
289
# ASL post-processing
258
- print ("[INFO] ASL - post-processing " )
259
- print (outputData [0 ].shape )
290
+ # print("[INFO] ASL - post-processing ")
291
+ # print(outputData[0].shape)
260
292
OutputData = outputData [0 ].reshape (1 ,29 )
261
293
asl_y = np .reshape ( OutputData , (- 1 ,29 ) )
262
294
asl_id = np .argmax (asl_y [0 ])
295
+ asl_sign = id_to_class [asl_id ]
263
296
264
- print ("[INFO] ASL - done " )
265
- cv2 .putText (output ,str (asl_id ),(10 ,10 ),text_fontType ,text_fontSize ,text_color ,text_lineSize ,text_lineType )
297
+ #print("[INFO] ASL - done ")
298
+ asl_text = '[' + str (asl_id )+ ']=' + asl_sign
299
+ cv2 .putText (output ,asl_text ,(10 ,30 ),text_fontType ,text_fontSize ,text_color ,text_lineSize ,text_lineType )
266
300
267
301
#except:
268
302
# print("ERROR : Exception occured during ASL classification ...")
269
303
270
304
271
- matching_text = ("[%04d] %02d" % (frame_count ,asl_id ))
305
+ matching_text = ("[%04d] [ %02d]=%s " % (frame_count ,asl_id , asl_sign ))
272
306
print (matching_text )
273
307
274
308
# display real-time FPS counter (if valid)
0 commit comments