{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualize Human Pose MPI Dataset" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%reload_ext autoreload\n", "%autoreload 2\n", "\n", "import os\n", "from os.path import join\n", "import math\n", "from glob import glob\n", "from random import randint\n", "\n", "import cv2 as cv\n", "import numpy as np\n", "import pandas as pd\n", "from PIL import Image, ImageDraw\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import scipy.io\n", "from pathlib import Path\n", "from sklearn import preprocessing\n", "from tqdm import tqdm_notebook as tqdm\n", "\n", "import sys\n", "sys.path.append('/work/megapixels_dev/megapixels/')\n", "from app.settings import app_cfg as cfg\n", "from app.utils import file_utils" ] }, { "cell_type": "code", "execution_count": 654, "metadata": {}, "outputs": [], "source": [ "# function to create spaced colormaps as RGB values\n", "\n", "import matplotlib as mpl\n", "import matplotlib.cm as mplcm\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "\n", "def get_color_map(cmap='prism', ncolors=20, as_hex=False, reverse=False, bgr=True):\n", " norm = mpl.colors.Normalize(vmin=0, vmax=ncolors-1)\n", " scalars = mplcm.ScalarMappable(norm=norm, cmap=cmap)\n", " colors = [scalars.to_rgba(i) for i in range(ncolors)]\n", " colors = [(int(255*c[0]),int(255*c[1]),int(255*c[2])) for c in colors] \n", " if reverse:\n", " colors = colors[::-1]\n", " if bgr:\n", " colors = [c[::-1] for c in colors]\n", " if as_hex:\n", " colors = ['#{:02x}{:02x}{:02x}'.format(c[0],c[1],c[2]) for c in colors]\n", " return colors\n", "\n", "def jitter_clr(clr, amt=10, mono=False):\n", " clr = list(clr)\n", " if mono:\n", " r = randint(-amt, amt)\n", " for i in range(len(clr)):\n", " clr[i] = max(0, min(255, clr[i] + r))\n", " else:\n", " for i in range(len(clr)):\n", " r = randint(-amt, amt)\n", " clr[i] = max(0, min(255, clr[i] + r))\n", " return clr" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "DATA_STORE = '/data_store_nas/'\n", "fp_dataset = join(DATA_STORE, 'datasets/people/youtube_poses')\n", "dir_fp_frames = join(fp_dataset, 'YouTube_Pose_dataset_1.0/GT_frames')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "dirs_frames = glob(join(dir_fp_frames, '*'))\n", "fps_frames = {}\n", "for dir_frames in dirs_frames:\n", " fps_frames[dir_frames] = join(dir_frames, '*')" ] }, { "cell_type": "code", "execution_count": 462, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['crop_x1',\n", " 'crop_x2',\n", " 'crop_y1',\n", " 'crop_y2',\n", " 'elbow_left_x',\n", " 'elbow_left_y',\n", " 'elbow_right_x',\n", " 'elbow_right_y',\n", " 'head_x',\n", " 'head_y',\n", " 'height',\n", " 'scale',\n", " 'shoulder_left_x',\n", " 'shoulder_left_y',\n", " 'shoulder_right_x',\n", " 'shoulder_right_y',\n", " 'video_id',\n", " 'width',\n", " 'wrist_left_x',\n", " 'wrist_left_y',\n", " 'wrist_right_x',\n", " 'wrist_right_y']\n" ] } ], "source": [ "from pprint import pprint\n", "pprint(list(df_poses.keys()))" ] }, { "cell_type": "code", "execution_count": 681, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | crop_x1 | \n", "crop_x2 | \n", "crop_y1 | \n", "crop_y2 | \n", "elbow_left_x | \n", "elbow_left_y | \n", "elbow_right_x | \n", "elbow_right_y | \n", "head_x | \n", "head_y | \n", "... | \n", "shoulder_left_x | \n", "shoulder_left_y | \n", "shoulder_right_x | \n", "shoulder_right_y | \n", "video_id | \n", "width | \n", "wrist_left_x | \n", "wrist_left_y | \n", "wrist_right_x | \n", "wrist_right_y | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "277.721438 | \n", "192.416331 | \n", "147.628696 | \n", "169.326277 | \n", "195.498320 | \n", "81.471438 | \n", "... | \n", "254.631384 | \n", "127.088374 | \n", "178.603159 | \n", "134.691196 | \n", "-osma2n86oA | \n", "720 | \n", "278.566196 | \n", "235.498992 | \n", "158.047379 | \n", "122.301411 | \n", "
| 1 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "273.497648 | \n", "187.629368 | \n", "152.134073 | \n", "129.341062 | \n", "207.324933 | \n", "72.742272 | \n", "... | \n", "254.349798 | \n", "131.593750 | \n", "181.137433 | \n", "123.990927 | \n", "-osma2n86oA | \n", "720 | \n", "274.342406 | \n", "235.498992 | \n", "135.238911 | \n", "91.608535 | \n", "
| 2 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "258.010417 | \n", "159.752352 | \n", "160.581653 | \n", "143.138777 | \n", "229.007056 | \n", "76.966062 | \n", "... | \n", "250.407594 | \n", "125.117272 | \n", "190.992944 | \n", "117.232863 | \n", "-osma2n86oA | \n", "720 | \n", "213.801411 | \n", "108.785282 | \n", "181.982191 | \n", "89.074261 | \n", "
| 3 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "274.342406 | \n", "188.192540 | \n", "142.841734 | \n", "110.193212 | \n", "203.101142 | \n", "76.402890 | \n", "... | \n", "253.786626 | \n", "128.777890 | \n", "185.361223 | \n", "120.611895 | \n", "-osma2n86oA | \n", "720 | \n", "276.595094 | \n", "231.556788 | \n", "156.921035 | \n", "55.847110 | \n", "
| 4 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "272.371304 | \n", "194.387433 | \n", "225.628024 | \n", "164.820901 | \n", "245.902218 | \n", "93.016465 | \n", "... | \n", "255.476142 | \n", "139.478159 | \n", "183.390121 | \n", "126.806788 | \n", "-osma2n86oA | \n", "720 | \n", "305.316868 | \n", "172.423723 | \n", "278.284610 | \n", "165.102487 | \n", "
5 rows × 22 columns
\n", "| \n", " | crop_x1 | \n", "crop_x2 | \n", "crop_y1 | \n", "crop_y2 | \n", "elbow_left_x | \n", "elbow_left_y | \n", "elbow_right_x | \n", "elbow_right_y | \n", "head_x | \n", "head_y | \n", "... | \n", "shoulder_left_x | \n", "shoulder_left_y | \n", "shoulder_right_x | \n", "shoulder_right_y | \n", "video_id | \n", "width | \n", "wrist_left_x | \n", "wrist_left_y | \n", "wrist_right_x | \n", "wrist_right_y | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "0.084867 | \n", "0.064402 | \n", "-0.095817 | \n", "0.046363 | \n", "-0.029332 | \n", "-0.022274 | \n", "... | \n", "0.052797 | \n", "0.013364 | \n", "-0.052797 | \n", "0.019304 | \n", "-osma2n86oA | \n", "720 | \n", "0.086040 | \n", "0.098060 | \n", "-0.081347 | \n", "0.009625 | \n", "
| 1 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "0.077436 | \n", "0.068252 | \n", "-0.091124 | \n", "0.022714 | \n", "-0.014470 | \n", "-0.021504 | \n", "... | \n", "0.050842 | \n", "0.024474 | \n", "-0.050842 | \n", "0.018534 | \n", "-osma2n86oA | \n", "720 | \n", "0.078609 | \n", "0.105650 | \n", "-0.114590 | \n", "-0.006765 | \n", "
| 2 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "0.051820 | \n", "0.047408 | \n", "-0.083498 | \n", "0.034428 | \n", "0.011537 | \n", "-0.017269 | \n", "... | \n", "0.041260 | \n", "0.020349 | \n", "-0.041260 | \n", "0.014189 | \n", "-osma2n86oA | \n", "720 | \n", "-0.009582 | \n", "0.007590 | \n", "-0.053775 | \n", "-0.007810 | \n", "
| 3 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "0.076067 | \n", "0.068472 | \n", "-0.106572 | \n", "0.007535 | \n", "-0.022879 | \n", "-0.018864 | \n", "... | \n", "0.047518 | \n", "0.022054 | \n", "-0.047518 | \n", "0.015674 | \n", "-osma2n86oA | \n", "720 | \n", "0.079196 | \n", "0.102350 | \n", "-0.087018 | \n", "-0.034923 | \n", "
| 4 | \n", "1 | \n", "1920 | \n", "1 | \n", "1080 | \n", "0.073525 | \n", "0.063522 | \n", "0.008604 | \n", "0.040423 | \n", "0.036763 | \n", "-0.015674 | \n", "... | \n", "0.050060 | \n", "0.020624 | \n", "-0.050060 | \n", "0.010724 | \n", "-osma2n86oA | \n", "720 | \n", "0.119283 | \n", "0.046363 | \n", "0.081738 | \n", "0.040643 | \n", "
5 rows × 22 columns
\n", "