forked from AISaturdaysLagos/Cohort8-Team-Template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from rileydrizzy/main
merge
- Loading branch information
Showing
26 changed files
with
1,681 additions
and
912 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,29 @@ | ||
name: Units Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
units-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.10 | ||
|
||
- name: Pytest | ||
run: | | ||
cd linguify | ||
pytest |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# NSL2AUDIOO | ||
# NSL-2-AUDIO | ||
|
||
[![LICENSE](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE) | ||
[![Python](https://img.shields.io/badge/python-3.10-blue.svg?style=flat-square)](https://www.python.org/) | ||
|
@@ -52,13 +52,13 @@ $ make setup | |
$ source $(poetry env info --path)/bin/activate | ||
``` | ||
|
||
## Project Roadmap | ||
### Project Roadmap | ||
|
||
Here's a glimpse of the exciting features we plan to implement in the coming weeks: | ||
|
||
|
||
|
||
## Citation | ||
- [x] Add project's documentation | ||
- [] Develop a Proof of Concept System | ||
- [] Deployment of Proof of Concept System | ||
|
||
## Acknowledgments | ||
|
||
|
@@ -68,10 +68,6 @@ I would like to acknowledge the outstanding contributions of : | |
**Email:** <[email protected]> | ||
**GitHub:** [@tejuafonja](https://github.com/tejuafonja) | ||
|
||
**Name:** Fola Animashaun ***(```Mentor```)*** | ||
**Email:** <[email protected]> | ||
**GitHub:** [@Modinat-A](https://github.com/Modinat-A) | ||
|
||
## Contact | ||
|
||
**Name:** **Ipadeola Ezekiel Ladipo** | ||
|
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
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,203 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def resize_pad(x):\n", | ||
" if x.shape[0] < FRAME_LEN:\n", | ||
" x = F.pad(x, (0, 0, 0, FRAME_LEN - x.shape[0], 0, 0))\n", | ||
" else:\n", | ||
" x = x.unsqueeze(0) # Add batch and channel dimensions\n", | ||
" x = torch.nn.functional.interpolate(\n", | ||
" x, size=(FRAME_LEN, x.shape[1]), mode=\"bilinear\", align_corners=False\n", | ||
" ).squeeze(0)\n", | ||
"\n", | ||
" return x\n", | ||
"\n", | ||
"\n", | ||
"def frames_preprocess(x):\n", | ||
" x = torch.tensor(x)\n", | ||
" rhand = x[:, RHAND_IDX]\n", | ||
" lhand = x[:, LHAND_IDX]\n", | ||
" rpose = x[:, RPOSE_IDX]\n", | ||
" lpose = x[:, LPOSE_IDX]\n", | ||
"\n", | ||
" rnan_idx = torch.any(torch.isnan(rhand), dim=1)\n", | ||
" lnan_idx = torch.any(torch.isnan(lhand), dim=1)\n", | ||
"\n", | ||
" rnans = torch.sum(rnan_idx)\n", | ||
" lnans = torch.sum(lnan_idx)\n", | ||
"\n", | ||
" if rnans > lnans:\n", | ||
" hand = lhand\n", | ||
" pose = lpose\n", | ||
"\n", | ||
" hand_x = hand[:, 0 * (len(LHAND_IDX) // 3) : 1 * (len(LHAND_IDX) // 3)]\n", | ||
" hand_y = hand[:, 1 * (len(LHAND_IDX) // 3) : 2 * (len(LHAND_IDX) // 3)]\n", | ||
" hand_z = hand[:, 2 * (len(LHAND_IDX) // 3) : 3 * (len(LHAND_IDX) // 3)]\n", | ||
" hand = torch.cat([1 - hand_x, hand_y, hand_z], dim=1)\n", | ||
"\n", | ||
" pose_x = pose[:, 0 * (len(LPOSE_IDX) // 3) : 1 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose_y = pose[:, 1 * (len(LPOSE_IDX) // 3) : 2 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose_z = pose[:, 2 * (len(LPOSE_IDX) // 3) : 3 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose = torch.cat([1 - pose_x, pose_y, pose_z], dim=1)\n", | ||
" else:\n", | ||
" hand = rhand\n", | ||
" pose = rpose\n", | ||
"\n", | ||
" hand_x = hand[:, 0 * (len(LHAND_IDX) // 3) : 1 * (len(LHAND_IDX) // 3)]\n", | ||
" hand_y = hand[:, 1 * (len(LHAND_IDX) // 3) : 2 * (len(LHAND_IDX) // 3)]\n", | ||
" hand_z = hand[:, 2 * (len(LHAND_IDX) // 3) : 3 * (len(LHAND_IDX) // 3)]\n", | ||
" hand = torch.cat(\n", | ||
" [hand_x.unsqueeze(-1), hand_y.unsqueeze(-1), hand_z.unsqueeze(-1)], dim=-1\n", | ||
" )\n", | ||
"\n", | ||
" mean = torch.mean(hand, dim=1).unsqueeze(1)\n", | ||
" std = torch.std(hand, dim=1).unsqueeze(1)\n", | ||
" hand = (hand - mean) / std\n", | ||
"\n", | ||
" pose_x = pose[:, 0 * (len(LPOSE_IDX) // 3) : 1 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose_y = pose[:, 1 * (len(LPOSE_IDX) // 3) : 2 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose_z = pose[:, 2 * (len(LPOSE_IDX) // 3) : 3 * (len(LPOSE_IDX) // 3)]\n", | ||
" pose = torch.cat(\n", | ||
" [pose_x.unsqueeze(-1), pose_y.unsqueeze(-1), pose_z.unsqueeze(-1)], dim=-1\n", | ||
" )\n", | ||
"\n", | ||
" x = torch.cat([hand, pose], dim=1)\n", | ||
" # print(f\"befor re{x.shape}\")\n", | ||
" x = resize_pad(x)\n", | ||
" # print(f\"after re{x.shape}\")\n", | ||
" x = torch.where(torch.isnan(x), torch.zeros_like(x), x)\n", | ||
" # print(x.shape)\n", | ||
"\n", | ||
" #! CRITICAL Debug\n", | ||
" # x = x.view(FRAME_LEN, len(LHAND_IDX) + len(LPOSE_IDX))\n", | ||
" return x" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\"\"\"doc\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"FRAME_LEN = 128\n", | ||
"\n", | ||
"LPOSE = [13, 15, 17, 19, 21]\n", | ||
"RPOSE = [14, 16, 18, 20, 22]\n", | ||
"POSE = LPOSE + RPOSE\n", | ||
"\n", | ||
"X = (\n", | ||
" [f\"x_right_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"x_left_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"x_pose_{i}\" for i in POSE]\n", | ||
")\n", | ||
"Y = (\n", | ||
" [f\"y_right_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"y_left_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"y_pose_{i}\" for i in POSE]\n", | ||
")\n", | ||
"Z = (\n", | ||
" [f\"z_right_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"z_left_hand_{i}\" for i in range(21)]\n", | ||
" + [f\"z_pose_{i}\" for i in POSE]\n", | ||
")\n", | ||
"\n", | ||
"FEATURE_COLUMNS = X + Y + Z\n", | ||
"\n", | ||
"X_IDX = [i for i, col in enumerate(FEATURE_COLUMNS) if \"x_\" in col]\n", | ||
"Y_IDX = [i for i, col in enumerate(FEATURE_COLUMNS) if \"y_\" in col]\n", | ||
"Z_IDX = [i for i, col in enumerate(FEATURE_COLUMNS) if \"z_\" in col]\n", | ||
"\n", | ||
"RHAND_IDX = [i for i, col in enumerate(FEATURE_COLUMNS) if \"right\" in col]\n", | ||
"LHAND_IDX = [i for i, col in enumerate(FEATURE_COLUMNS) if \"left\" in col]\n", | ||
"RPOSE_IDX = [\n", | ||
" i\n", | ||
" for i, col in enumerate(FEATURE_COLUMNS)\n", | ||
" if \"pose\" in col and int(col[-2:]) in RPOSE\n", | ||
"]\n", | ||
"LPOSE_IDX = [\n", | ||
" i\n", | ||
" for i, col in enumerate(FEATURE_COLUMNS)\n", | ||
" if \"pose\" in col and int(col[-2:]) in LPOSE\n", | ||
"]\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"(63, 63)" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"len(RHAND_IDX), len(LHAND_IDX)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def read_file(file, file_id, landmarks_metadata_path):\n", | ||
" phrase_list = []\n", | ||
" frames_list = []\n", | ||
" metadata_train_dataframe = pd.read_csv(landmarks_metadata_path)\n", | ||
" file_id_df = metadata_train_dataframe.loc[\n", | ||
" metadata_train_dataframe[\"file_id\"] == file_id\n", | ||
" ]\n", | ||
" saved_parueat_df = pq.read_table(\n", | ||
" file, columns=[\"sequence_id\"] + FEATURE_COLUMNS\n", | ||
" ).to_pandas()\n", | ||
" for seq_id, phrase in zip(file_id_df.sequence_id, file_id_df.phrase):\n", | ||
" frames = saved_parueat_df[saved_parueat_df.index == seq_id].to_numpy()\n", | ||
" # NaN\n", | ||
" right_num_nan = np.sum(np.sum(np.isnan(frames[:, RHAND_IDX]), axis=1) == 0)\n", | ||
" left_num_nan = np.sum(np.sum(np.isnan(frames[:, LHAND_IDX]), axis=1) == 0)\n", | ||
" \n", | ||
" total_num_nan = max(right_num_nan, left_num_nan)\n", | ||
" if 2 * len(phrase) < total_num_nan:\n", | ||
" frames_list.append(frames)\n", | ||
" phrase_list.append(phrase)\n", | ||
" return (frames_list, phrase_list)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
Oops, something went wrong.