movenet
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| movenet [2021/10/09 08:43] – serge | movenet [2021/12/16 09:07] (Version actuelle) – [Ressources] serge | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== MoveNet ====== | ====== MoveNet ====== | ||
| + | =====Ressources===== | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| - | ====Exemple==== | + | =====Optimisation de Tensorflow ===== |
| + | Movenet appelle Tensorflow Lite, qui n'est pas optimisé pour GPU. Inutile d' | ||
| + | Il ne tourne que sur CPU, et demande à avoir AVX2 et FMA.\\ | ||
| + | Pour compiler Tensorflow, voir **[[linux_compiler_tensorflow_avec_bazel|]]** | ||
| + | |||
| + | Altrnatives, | ||
| + | * https:// | ||
| + | |||
| + | =====Exemple===== | ||
| * https:// | * https:// | ||
| - | <code python> | + | <file python |
| from time import time | from time import time | ||
| import cv2 | import cv2 | ||
| Ligne 14: | Ligne 23: | ||
| def draw(frame, keypoints_with_scores): | def draw(frame, keypoints_with_scores): | ||
| - | """ | ||
| for item in keypoints_with_scores[0][0]: | for item in keypoints_with_scores[0][0]: | ||
| - | if item[2] > 0.5: | + | if item[2] > 0.3: # confiance |
| - | x = int(item[1]*640) | + | x = int(item[1]*720) # numpy array x est le 2ème |
| - | y = int(item[0]*640) - 80 | + | y = int(item[0]*720) |
| cv2.circle(frame, | cv2.circle(frame, | ||
| return frame | return frame | ||
| - | interpreter | + | models |
| + | "lite-model_movenet_singlepose_thunder_tflite_float16_4.tflite", | ||
| + | | ||
| + | |||
| + | interpreter = tf.lite.Interpreter(model_path=models[0]) | ||
| interpreter.allocate_tensors() | interpreter.allocate_tensors() | ||
| cv2.namedWindow(' | cv2.namedWindow(' | ||
| - | cam = cv2.VideoCapture(0) | + | cam = cv2.VideoCapture(2) |
| + | cam.set(cv2.CAP_PROP_FRAME_WIDTH, | ||
| + | cam.set(cv2.CAP_PROP_FRAME_HEIGHT, | ||
| t0 = time() | t0 = time() | ||
| nbr = 0 | nbr = 0 | ||
| Ligne 37: | Ligne 52: | ||
| if not ret: | if not ret: | ||
| continue | continue | ||
| + | |||
| + | # Extraction d'une image carrée [rows, columns] | ||
| + | frame = frame[:, 280:1000] | ||
| image = tf.expand_dims(frame, | image = tf.expand_dims(frame, | ||
| Ligne 68: | Ligne 86: | ||
| cv2.destroyAllWindows() | cv2.destroyAllWindows() | ||
| - | </code> | + | </file> |
| + | |||
| + | =====Des essais amusants===== | ||
| + | * **[[https:// | ||
| + | |||
| + | |||
| + | |||
| + | {{tag> | ||
movenet.1633768995.txt.gz · Dernière modification : de serge
