Skip to content

Commit

Permalink
Merge pull request #8 from rileydrizzy/main
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
rileydrizzy authored Dec 12, 2023
2 parents 0299456 + 0b56537 commit 4ce300d
Show file tree
Hide file tree
Showing 26 changed files with 1,681 additions and 912 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/run_units_test.yml
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
14 changes: 5 additions & 9 deletions README.md
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/)
Expand Down Expand Up @@ -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

Expand All @@ -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**
Expand Down
19 changes: 18 additions & 1 deletion linguify_yb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,21 @@

***Overview:*** \

# Project Roadmap
## Project Roadmap

- **[Month Year]:** Project Initiation
- **[Month Year]:** Core Functionality Completion
- **[Month Year]:** User Interface Design Completion
- **[Month Year]:** Data Integration Completion
- **[Month Year]:** Testing and Quality Assurance Completion
- **[Month Year]:** Deployment to Production

## How to Contribute

We welcome contributions from the community. If you're interested in contributing, please refer to the [Contributing Guidelines](CONTRIBUTING.md).

## Support and Contact

If you have questions or need assistance, feel free to reach out to [Your Contact Information].

---
203 changes: 203 additions & 0 deletions linguify_yb/development/code_dev.ipynb
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
}
39 changes: 0 additions & 39 deletions linguify_yb/development/data_dev.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,6 @@
"import pyarrow.parquet as pq"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total Space: 1399.98 GB\n",
"Used Space: 455.25 GB\n",
"Free Space: 944.73 GB\n",
"Percentage Used: 32.50%\n"
]
}
],
"source": [
"import psutil\n",
"\n",
"def get_storage_space():\n",
" # Get disk usage statistics\n",
" disk_usage = psutil.disk_usage('/')\n",
"\n",
" # Extract relevant information\n",
" total_space = disk_usage.total # Total storage space\n",
" used_space = disk_usage.used # Used storage space\n",
" free_space = disk_usage.free # Free storage space\n",
" percent_used = disk_usage.percent # Percentage of used space\n",
"\n",
" # Print or return the information\n",
" print(f\"Total Space: {total_space / (1024 ** 3):.2f} GB\")\n",
" print(f\"Used Space: {used_space / (1024 ** 3):.2f} GB\")\n",
" print(f\"Free Space: {free_space / (1024 ** 3):.2f} GB\")\n",
" print(f\"Percentage Used: {percent_used:.2f}%\")\n",
"\n",
"# Call the function to get storage space information\n",
"get_storage_space()\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
Expand Down
Loading

0 comments on commit 4ce300d

Please sign in to comment.