-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d838910
commit 3f66183
Showing
12 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
keypoint.csv filter=lfs diff=lfs merge=lfs -text | ||
point_history.csv filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,3 +129,5 @@ dmypy.json | |
.pyre/ | ||
|
||
.DS_Store | ||
|
||
.idea/ |
Git LFS file not shown
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import numpy as np | ||
import tensorflow as tf | ||
|
||
|
||
class KeyPointClassifier(object): | ||
def __init__( | ||
self, | ||
model_path='model/keypoint_classifier/keypoint_classifier.tflite', | ||
num_threads=1, | ||
): | ||
self.interpreter = tf.lite.Interpreter(model_path=model_path, | ||
num_threads=num_threads) | ||
|
||
self.interpreter.allocate_tensors() | ||
self.input_details = self.interpreter.get_input_details() | ||
self.output_details = self.interpreter.get_output_details() | ||
|
||
def __call__( | ||
self, | ||
landmark_list, | ||
): | ||
input_details_tensor_index = self.input_details[0]['index'] | ||
self.interpreter.set_tensor( | ||
input_details_tensor_index, | ||
np.array([landmark_list], dtype=np.float32)) | ||
self.interpreter.invoke() | ||
|
||
output_details_tensor_index = self.output_details[0]['index'] | ||
|
||
result = self.interpreter.get_tensor(output_details_tensor_index) | ||
|
||
result_index = np.argmax(np.squeeze(result)) | ||
|
||
return result_index |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Open | ||
Close | ||
Pointer | ||
OK |
Git LFS file not shown
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
model/point_history_classifier/point_history_classifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import numpy as np | ||
import tensorflow as tf | ||
|
||
|
||
class PointHistoryClassifier(object): | ||
def __init__( | ||
self, | ||
model_path='model/point_history_classifier/point_history_classifier.tflite', | ||
score_th=0.5, | ||
invalid_value=0, | ||
num_threads=1, | ||
): | ||
self.interpreter = tf.lite.Interpreter(model_path=model_path, | ||
num_threads=num_threads) | ||
|
||
self.interpreter.allocate_tensors() | ||
self.input_details = self.interpreter.get_input_details() | ||
self.output_details = self.interpreter.get_output_details() | ||
|
||
self.score_th = score_th | ||
self.invalid_value = invalid_value | ||
|
||
def __call__( | ||
self, | ||
point_history, | ||
): | ||
input_details_tensor_index = self.input_details[0]['index'] | ||
self.interpreter.set_tensor( | ||
input_details_tensor_index, | ||
np.array([point_history], dtype=np.float32)) | ||
self.interpreter.invoke() | ||
|
||
output_details_tensor_index = self.output_details[0]['index'] | ||
|
||
result = self.interpreter.get_tensor(output_details_tensor_index) | ||
|
||
result_index = np.argmax(np.squeeze(result)) | ||
|
||
if np.squeeze(result)[result_index] < self.score_th: | ||
result_index = self.invalid_value | ||
|
||
return result_index |
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
model/point_history_classifier/point_history_classifier_label.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Stop | ||
Clockwise | ||
Counter Clockwise | ||
Move |