maatt4face commited on
Commit
ecae020
·
verified ·
1 Parent(s): e702789
Files changed (1) hide show
  1. Final_Training.ipynb +270 -240
Final_Training.ipynb CHANGED
@@ -100,7 +100,7 @@
100
  },
101
  {
102
  "cell_type": "code",
103
- "execution_count": 28,
104
  "id": "9ba61cb6",
105
  "metadata": {},
106
  "outputs": [
@@ -113,12 +113,11 @@
113
  }
114
  ],
115
  "source": [
116
- "HF_USERNAME = 'maatt4face'\n",
117
- "\n",
118
  "# Admin =================================================================================\n",
119
  "import os\n",
120
  "DOWNLOAD_DIR = './training-data'\n",
121
  "CACHE_DIR = './cache-data'\n",
 
122
  "os.makedirs(DOWNLOAD_DIR, exist_ok=True)\n",
123
  "os.makedirs(CACHE_DIR, exist_ok=True)\n",
124
  "\n",
@@ -1329,7 +1328,15 @@
1329
  "id": "d482fc69",
1330
  "metadata": {},
1331
  "source": [
1332
- "## Training"
 
 
 
 
 
 
 
 
1333
  ]
1334
  },
1335
  {
@@ -1414,7 +1421,7 @@
1414
  },
1415
  {
1416
  "cell_type": "code",
1417
- "execution_count": null,
1418
  "id": "01258d83",
1419
  "metadata": {},
1420
  "outputs": [],
@@ -1446,7 +1453,7 @@
1446
  " # Tracking variables before the loop\n",
1447
  " best_val_loss = float('inf')\n",
1448
  " model_name = type(model).__name__\n",
1449
- " save_path = f\"best_model_weights_{model_name}.pth\"\n",
1450
  "\n",
1451
  " for epoch in range(MAX_EPOCHS):\n",
1452
  " # Train and Validate\n",
@@ -1719,225 +1726,16 @@
1719
  },
1720
  {
1721
  "cell_type": "markdown",
1722
- "id": "2937be7d",
1723
- "metadata": {},
1724
- "source": [
1725
- "## Hugging Face"
1726
- ]
1727
- },
1728
- {
1729
- "cell_type": "code",
1730
- "execution_count": null,
1731
- "id": "6a527bea",
1732
- "metadata": {},
1733
- "outputs": [],
1734
- "source": [
1735
- "!pip install huggingface_hub"
1736
- ]
1737
- },
1738
- {
1739
- "cell_type": "code",
1740
- "execution_count": null,
1741
- "id": "6cfc8a81",
1742
- "metadata": {},
1743
- "outputs": [
1744
- {
1745
- "name": "stdout",
1746
- "output_type": "stream",
1747
- "text": [
1748
- "^C\n"
1749
- ]
1750
- }
1751
- ],
1752
- "source": [
1753
- "!hf auth login"
1754
- ]
1755
- },
1756
- {
1757
- "cell_type": "markdown",
1758
- "id": "1c7806b8",
1759
- "metadata": {},
1760
- "source": [
1761
- "#### Admin"
1762
- ]
1763
- },
1764
- {
1765
- "cell_type": "code",
1766
- "execution_count": 4,
1767
- "id": "466d51ad",
1768
- "metadata": {},
1769
- "outputs": [],
1770
- "source": [
1771
- "import tqdm\n",
1772
- "from huggingface_hub import HfApi, hf_hub_download, login as HfLogin, logout as HfLogout\n",
1773
- "\n",
1774
- "hf_username = \"maatt4face\"\n",
1775
- "\n",
1776
- "# Login\n",
1777
- "def login():\n",
1778
- " try:\n",
1779
- " user_info = HfApi().whoami()\n",
1780
- " print(f\"Logged in as: {user_info['name']}\")\n",
1781
- " except Exception:\n",
1782
- " print(\"Logging in.\")\n",
1783
- " HfLogin()\n",
1784
- "\n",
1785
- "def logout():\n",
1786
- " try:\n",
1787
- " user_info = HfApi().whoami()\n",
1788
- " print(f\"Logging out: {user_info['name']}\")\n",
1789
- " HfLogout()\n",
1790
- " except Exception:\n",
1791
- " print(\"Not logged in.\")\n"
1792
- ]
1793
- },
1794
- {
1795
- "cell_type": "code",
1796
- "execution_count": null,
1797
- "id": "d38b8e1b",
1798
- "metadata": {},
1799
- "outputs": [],
1800
- "source": [
1801
- "print(HfApi().whoami())\n",
1802
- "# logout()\n",
1803
- "# login()"
1804
- ]
1805
- },
1806
- {
1807
- "cell_type": "markdown",
1808
- "id": "99d882c8",
1809
- "metadata": {},
1810
- "source": [
1811
- "#### File Upload"
1812
- ]
1813
- },
1814
- {
1815
- "cell_type": "code",
1816
- "execution_count": null,
1817
- "id": "4b7a2653",
1818
- "metadata": {},
1819
- "outputs": [],
1820
- "source": [
1821
- "# upload files\n",
1822
- "# Upload a single file (e.g., your trained model)\n",
1823
- "import os\n",
1824
- "\n",
1825
- "def create_repo(repo_id):\n",
1826
- " api = HfApi()\n",
1827
- "\n",
1828
- " # Create the repo first (if it already exists, this will just skip)\n",
1829
- " api.create_repo(\n",
1830
- " repo_id=repo_id,\n",
1831
- " repo_type=\"model\",\n",
1832
- " exist_ok=True, # Don't error if it already exists\n",
1833
- " private=False, # Make it public so TAs can access\n",
1834
- " )\n",
1835
- "\n",
1836
- "def upload_to_hub(repo_id, local_path, commit_msg=None, commit_desc=None):\n",
1837
- " api = HfApi()\n",
1838
- "\n",
1839
- " if os.path.isfile(local_path):\n",
1840
- " api.upload_file(\n",
1841
- " path_or_fileobj=local_path,\n",
1842
- " path_in_repo=local_path,\n",
1843
- " repo_id=repo_id,\n",
1844
- " repo_type=\"model\", # can be \"model\", \"dataset\", or \"space\"\n",
1845
- " commit_message=commit_msg,\n",
1846
- " commit_description=commit_desc\n",
1847
- " )\n",
1848
- " elif os.path.isdir(local_path):\n",
1849
- " # Upload an entire folder (e.g., weights + config + scripts)\n",
1850
- " api.upload_folder(\n",
1851
- " folder_path=local_path,\n",
1852
- " path_in_repo=local_path,\n",
1853
- " repo_id=repo_id,\n",
1854
- " repo_type=\"model\",\n",
1855
- " commit_message=commit_msg,\n",
1856
- " commit_description=commit_desc\n",
1857
- " )\n",
1858
- " else:\n",
1859
- " raise RuntimeError(f\"Ivalid Object {local_path}\")\n",
1860
- "\n",
1861
- "def delete_file(repo_id, remote_path, is_folder, commit_msg):\n",
1862
- " api = HfApi()\n",
1863
- "\n",
1864
- " if is_folder:\n",
1865
- " api.delete_folder(\n",
1866
- " path_in_repo=remote_path,\n",
1867
- " repo_id=repo_id,\n",
1868
- " commit_message=commit_msg\n",
1869
- " )\n",
1870
- " api.delete_file(\n",
1871
- " path_in_repo=remote_path,\n",
1872
- " repo_id=repo_id,\n",
1873
- " repo_type=\"model\", # can also be \"dataset\" or \"space\"\n",
1874
- " commit_message=commit_msg\n",
1875
- " )\n"
1876
- ]
1877
- },
1878
- {
1879
- "cell_type": "code",
1880
- "execution_count": null,
1881
- "id": "fc3da1cb",
1882
- "metadata": {},
1883
- "outputs": [
1884
- {
1885
- "data": {
1886
- "application/vnd.jupyter.widget-view+json": {
1887
- "model_id": "ad2872b5a4c5441b91a25a28f416f84d",
1888
- "version_major": 2,
1889
- "version_minor": 0
1890
- },
1891
- "text/plain": [
1892
- "Processing Files (0 / 0): | | 0.00B / 0.00B "
1893
- ]
1894
- },
1895
- "metadata": {},
1896
- "output_type": "display_data"
1897
- },
1898
- {
1899
- "data": {
1900
- "application/vnd.jupyter.widget-view+json": {
1901
- "model_id": "d0c4bb61312c48f1ab264c386ea06095",
1902
- "version_major": 2,
1903
- "version_minor": 0
1904
- },
1905
- "text/plain": [
1906
- "New Data Upload: | | 0.00B / 0.00B "
1907
- ]
1908
- },
1909
- "metadata": {},
1910
- "output_type": "display_data"
1911
- }
1912
- ],
1913
- "source": [
1914
- "repo_id = f\"{hf_username}/mv-final-assignment\"\n",
1915
- "create_repo(repo_id)\n",
1916
- "# Training File and Model Weights\n",
1917
- "upload_to_hub(repo_id, \"Final_Training.ipynb\", commit_msg=\"Added HF delete calls\")\n",
1918
- "# upload_to_hub(repo_id, \"best_model_weights_PushupCounterSingleOutput_v01.pth\", commit_msg=\"PushupCounterSingleOutput model weights\")\n",
1919
- "# upload_to_hub(repo_id, \"best_model_weights_PushupCounterSingleOutput.pth\", commit_msg=\"PushupCounterSingleOutput model weights\")\n",
1920
- "# upload_to_hub(repo_id, \"best_model_weights_PushupCounterMaxPool.pth\", commit_msg=\"PushupCounterMaxPool model weights\")\n",
1921
- "# YOLO Weights\n",
1922
- "# upload_to_hub(repo_id, YOLO_DIR, commit_msg=\"landpark detection weights\")\n",
1923
- "\n",
1924
- "delete_file(repo_id, \"botsort.yaml\", is_folder=False, commit_msg=\"Real Estate Organization\")\n",
1925
- "delete_file(repo_id, \"bytetrack.yaml\", is_folder=False, commit_msg=\"Real Estate Organization\")\n",
1926
- "delete_file(repo_id, \"yolo11n-pose.pt\", is_folder=False, commit_msg=\"Real Estate Organization\")"
1927
- ]
1928
- },
1929
- {
1930
- "cell_type": "markdown",
1931
- "id": "606affc6",
1932
  "metadata": {},
1933
  "source": [
1934
- "## Performance Plots"
1935
  ]
1936
  },
1937
  {
1938
  "cell_type": "code",
1939
  "execution_count": null,
1940
- "id": "892ba310",
1941
  "metadata": {},
1942
  "outputs": [],
1943
  "source": [
@@ -1996,37 +1794,27 @@
1996
  },
1997
  {
1998
  "cell_type": "markdown",
1999
- "id": "3aa64d74",
2000
  "metadata": {},
2001
  "source": [
2002
- "## Test Inference"
2003
  ]
2004
  },
2005
  {
2006
  "cell_type": "code",
2007
- "execution_count": null,
2008
- "id": "eed737e3",
2009
  "metadata": {},
2010
  "outputs": [
2011
  {
2012
- "name": "stderr",
2013
- "output_type": "stream",
2014
- "text": [
2015
- "C:\\Users\\drmaatt\\AppData\\Local\\Temp\\ipykernel_47360\\2981320948.py:26: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
2016
- " checkpoint = torch.load(save_path)\n"
2017
- ]
2018
- },
2019
- {
2020
- "name": "stdout",
2021
- "output_type": "stream",
2022
- "text": [
2023
- "[Video Load] Elapsed time: 1.0888 seconds\n",
2024
- "[Video Transformation] Elapsed time: 1.0897 seconds\n",
2025
- "[Feature Extraction] Elapsed time: 3.5884 seconds\n",
2026
- "[Featurn Engineering 1] Elapsed time: 0.0095 seconds\n",
2027
- "[Featurn Engineering 2] Elapsed time: 0.0015 seconds\n",
2028
- "[Prediction] Elapsed time: 0.0180 seconds\n",
2029
- "Predicted pushups: 3\n"
2030
  ]
2031
  }
2032
  ],
@@ -2150,6 +1938,248 @@
2150
  "predicted, angles_tensor, lengths = predict_pushups(os.path.join(DOWNLOAD_DIR, \"1_dksksjfwijf.mp4\"))\n",
2151
  "print(f\"Predicted pushups: {predicted}\")\n"
2152
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2153
  }
2154
  ],
2155
  "metadata": {
 
100
  },
101
  {
102
  "cell_type": "code",
103
+ "execution_count": null,
104
  "id": "9ba61cb6",
105
  "metadata": {},
106
  "outputs": [
 
113
  }
114
  ],
115
  "source": [
 
 
116
  "# Admin =================================================================================\n",
117
  "import os\n",
118
  "DOWNLOAD_DIR = './training-data'\n",
119
  "CACHE_DIR = './cache-data'\n",
120
+ "WEIGHTS_DIR = './model-weights'\n",
121
  "os.makedirs(DOWNLOAD_DIR, exist_ok=True)\n",
122
  "os.makedirs(CACHE_DIR, exist_ok=True)\n",
123
  "\n",
 
1328
  "id": "d482fc69",
1329
  "metadata": {},
1330
  "source": [
1331
+ "## Training and Testing"
1332
+ ]
1333
+ },
1334
+ {
1335
+ "cell_type": "markdown",
1336
+ "id": "e7f08201",
1337
+ "metadata": {},
1338
+ "source": [
1339
+ "### Training"
1340
  ]
1341
  },
1342
  {
 
1421
  },
1422
  {
1423
  "cell_type": "code",
1424
+ "execution_count": 43,
1425
  "id": "01258d83",
1426
  "metadata": {},
1427
  "outputs": [],
 
1453
  " # Tracking variables before the loop\n",
1454
  " best_val_loss = float('inf')\n",
1455
  " model_name = type(model).__name__\n",
1456
+ " save_path = os.path.join(WEIGHTS_DIR, f\"best_model_weights_{model_name}.pth\")\n",
1457
  "\n",
1458
  " for epoch in range(MAX_EPOCHS):\n",
1459
  " # Train and Validate\n",
 
1726
  },
1727
  {
1728
  "cell_type": "markdown",
1729
+ "id": "a836629b",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1730
  "metadata": {},
1731
  "source": [
1732
+ "### Performance Plots"
1733
  ]
1734
  },
1735
  {
1736
  "cell_type": "code",
1737
  "execution_count": null,
1738
+ "id": "83473ef3",
1739
  "metadata": {},
1740
  "outputs": [],
1741
  "source": [
 
1794
  },
1795
  {
1796
  "cell_type": "markdown",
1797
+ "id": "8319211b",
1798
  "metadata": {},
1799
  "source": [
1800
+ "### Testing"
1801
  ]
1802
  },
1803
  {
1804
  "cell_type": "code",
1805
+ "execution_count": 44,
1806
+ "id": "f2746ae5",
1807
  "metadata": {},
1808
  "outputs": [
1809
  {
1810
+ "ename": "NameError",
1811
+ "evalue": "name 'outputs' is not defined",
1812
+ "output_type": "error",
1813
+ "traceback": [
1814
+ "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
1815
+ "\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
1816
+ "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[44]\u001b[39m\u001b[32m, line 23\u001b[39m\n\u001b[32m 20\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m[\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m.name\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m] Elapsed time: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00melapsed\u001b[38;5;132;01m:\u001b[39;00m\u001b[33m.4f\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m seconds\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 22\u001b[39m \u001b[38;5;66;03m# Load the trained model\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m23\u001b[39m model = \u001b[43moutputs\u001b[49m[\u001b[33m\"\u001b[39m\u001b[33mmodel\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m 24\u001b[39m model_name = \u001b[38;5;28mtype\u001b[39m(model).\u001b[34m__name__\u001b[39m\n\u001b[32m 25\u001b[39m save_path = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mbest_model_weights_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodel_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m.pth\u001b[39m\u001b[33m\"\u001b[39m\n",
1817
+ "\u001b[31mNameError\u001b[39m: name 'outputs' is not defined"
 
 
 
 
 
 
 
 
 
 
1818
  ]
1819
  }
1820
  ],
 
1938
  "predicted, angles_tensor, lengths = predict_pushups(os.path.join(DOWNLOAD_DIR, \"1_dksksjfwijf.mp4\"))\n",
1939
  "print(f\"Predicted pushups: {predicted}\")\n"
1940
  ]
1941
+ },
1942
+ {
1943
+ "cell_type": "markdown",
1944
+ "id": "2937be7d",
1945
+ "metadata": {},
1946
+ "source": [
1947
+ "## Hugging Face"
1948
+ ]
1949
+ },
1950
+ {
1951
+ "cell_type": "markdown",
1952
+ "id": "9a1cf00c",
1953
+ "metadata": {},
1954
+ "source": [
1955
+ "### Command Lines"
1956
+ ]
1957
+ },
1958
+ {
1959
+ "cell_type": "code",
1960
+ "execution_count": null,
1961
+ "id": "6a527bea",
1962
+ "metadata": {},
1963
+ "outputs": [],
1964
+ "source": [
1965
+ "!pip install huggingface_hub"
1966
+ ]
1967
+ },
1968
+ {
1969
+ "cell_type": "code",
1970
+ "execution_count": null,
1971
+ "id": "6cfc8a81",
1972
+ "metadata": {},
1973
+ "outputs": [
1974
+ {
1975
+ "name": "stdout",
1976
+ "output_type": "stream",
1977
+ "text": [
1978
+ "^C\n"
1979
+ ]
1980
+ }
1981
+ ],
1982
+ "source": [
1983
+ "!hf auth login"
1984
+ ]
1985
+ },
1986
+ {
1987
+ "cell_type": "markdown",
1988
+ "id": "1c7806b8",
1989
+ "metadata": {},
1990
+ "source": [
1991
+ "### Code"
1992
+ ]
1993
+ },
1994
+ {
1995
+ "cell_type": "markdown",
1996
+ "id": "d4a13690",
1997
+ "metadata": {},
1998
+ "source": [
1999
+ "#### Admin"
2000
+ ]
2001
+ },
2002
+ {
2003
+ "cell_type": "code",
2004
+ "execution_count": 41,
2005
+ "id": "466d51ad",
2006
+ "metadata": {},
2007
+ "outputs": [],
2008
+ "source": [
2009
+ "import tqdm\n",
2010
+ "from huggingface_hub import HfApi, hf_hub_download, login as HfLogin, logout as HfLogout\n",
2011
+ "\n",
2012
+ "class HugMyFace:\n",
2013
+ " def __init__(self, username, repo_id):\n",
2014
+ " self.username = username\n",
2015
+ " self.repo_id = repo_id\n",
2016
+ " self.api = HfApi()\n",
2017
+ "\n",
2018
+ " def login(self):\n",
2019
+ " try:\n",
2020
+ " user_info = self.api.whoami()\n",
2021
+ " print(f\"Logged in as: {user_info['name']}\")\n",
2022
+ " except Exception:\n",
2023
+ " print(\"Logging in.\")\n",
2024
+ " HfLogin()\n",
2025
+ "\n",
2026
+ " def logout(self):\n",
2027
+ " try:\n",
2028
+ " user_info = self.api.whoami()\n",
2029
+ " print(f\"Logging out: {user_info['name']}\")\n",
2030
+ " HfLogout()\n",
2031
+ " except Exception:\n",
2032
+ " print(\"Not logged in.\")\n",
2033
+ "\n",
2034
+ " def whoami(self):\n",
2035
+ " user_info = self.api.whoami()\n",
2036
+ " print(f\"{user_info}\")\n",
2037
+ "\n",
2038
+ " def create_repo(self):\n",
2039
+ " # Create the repo first (if it already exists, this will just skip)\n",
2040
+ " self.api.create_repo(\n",
2041
+ " repo_id=self.repo_id,\n",
2042
+ " repo_type=\"model\",\n",
2043
+ " exist_ok=True, # Don't error if it already exists\n",
2044
+ " private=False, # Make it public so TAs can access\n",
2045
+ " )\n",
2046
+ " \n",
2047
+ " def list_repo(self):\n",
2048
+ " repo_info = self.api.repo_info(repo_id=self.repo_id)\n",
2049
+ " print(f\"[{[f.rfilename for f in repo_info.siblings]}]\")\n",
2050
+ "\n",
2051
+ " def upload_to_hub(self, local_path, commit_msg=None, commit_desc=None):\n",
2052
+ " if os.path.isfile(local_path):\n",
2053
+ " self.api.upload_file(\n",
2054
+ " path_or_fileobj=local_path,\n",
2055
+ " path_in_repo=local_path,\n",
2056
+ " repo_id=self.repo_id,\n",
2057
+ " repo_type=\"model\", # can be \"model\", \"dataset\", or \"space\"\n",
2058
+ " commit_message=commit_msg,\n",
2059
+ " commit_description=commit_desc\n",
2060
+ " )\n",
2061
+ " elif os.path.isdir(self, local_path):\n",
2062
+ " # Upload an entire folder (e.g., weights + config + scripts)\n",
2063
+ " self.api.upload_folder(\n",
2064
+ " folder_path=local_path,\n",
2065
+ " path_in_repo=local_path,\n",
2066
+ " repo_id=self.repo_id,\n",
2067
+ " repo_type=\"model\",\n",
2068
+ " commit_message=commit_msg,\n",
2069
+ " commit_description=commit_desc\n",
2070
+ " )\n",
2071
+ " else:\n",
2072
+ " raise RuntimeError(f\"Ivalid Object {local_path}\")\n",
2073
+ "\n",
2074
+ " def delete_file(self, remote_path, is_folder, commit_msg):\n",
2075
+ " if is_folder:\n",
2076
+ " self.api.delete_folder(\n",
2077
+ " path_in_repo=remote_path,\n",
2078
+ " repo_id=self.repo_id,\n",
2079
+ " commit_message=commit_msg\n",
2080
+ " )\n",
2081
+ " else:\n",
2082
+ " self.api.delete_file(\n",
2083
+ " path_in_repo=remote_path,\n",
2084
+ " repo_id=self.repo_id,\n",
2085
+ " repo_type=\"model\", # can also be \"dataset\" or \"space\"\n",
2086
+ " commit_message=commit_msg\n",
2087
+ " )"
2088
+ ]
2089
+ },
2090
+ {
2091
+ "cell_type": "code",
2092
+ "execution_count": 42,
2093
+ "id": "d38b8e1b",
2094
+ "metadata": {},
2095
+ "outputs": [],
2096
+ "source": [
2097
+ "HF_USERNAME = 'maatt4face'\n",
2098
+ "HF_REPO_ID = f\"{HF_USERNAME}/mv-final-assignment\"\n",
2099
+ "HF = HugMyFace(HF_USERNAME, HF_REPO_ID)"
2100
+ ]
2101
+ },
2102
+ {
2103
+ "cell_type": "markdown",
2104
+ "id": "99d882c8",
2105
+ "metadata": {},
2106
+ "source": [
2107
+ "#### Repo Interactions"
2108
+ ]
2109
+ },
2110
+ {
2111
+ "cell_type": "code",
2112
+ "execution_count": null,
2113
+ "id": "fc3da1cb",
2114
+ "metadata": {},
2115
+ "outputs": [],
2116
+ "source": [
2117
+ "\n",
2118
+ "HF.create_repo()\n",
2119
+ "\n",
2120
+ "# Training File and Model Weights\n",
2121
+ "HF.upload_to_hub(\"Final_Training.ipynb\", commit_msg=\"Clean up\")\n",
2122
+ "HF.upload_to_hub(WEIGHTS_DIR, commit_msg=\"Model weights\")\n",
2123
+ "# upload_to_hub(\"best_model_weights_PushupCounterSingleOutput_v01.pth\", commit_msg=\"PushupCounterSingleOutput model weights\")\n",
2124
+ "# upload_to_hub(\"best_model_weights_PushupCounterSingleOutput.pth\", commit_msg=\"PushupCounterSingleOutput model weights\")\n",
2125
+ "# upload_to_hub(\"best_model_weights_PushupCounterMaxPool.pth\", commit_msg=\"PushupCounterMaxPool model weights\")\n",
2126
+ "\n",
2127
+ "# YOLO Weights\n",
2128
+ "# HF.upload_to_hub(YOLO_DIR, commit_msg=\"landpark detection weights\")\n",
2129
+ "# delete_file(\"botsort.yaml\", is_folder=False, commit_msg=\"Real Estate Organization\")\n",
2130
+ "# delete_file(\"bytetrack.yaml\", is_folder=False, commit_msg=\"Real Estate Organization\")\n",
2131
+ "# delete_file(\"yolo11n-pose.pt\", is_folder=False, commit_msg=\"Real Estate Organization\")"
2132
+ ]
2133
+ },
2134
+ {
2135
+ "cell_type": "markdown",
2136
+ "id": "606affc6",
2137
+ "metadata": {},
2138
+ "source": []
2139
+ },
2140
+ {
2141
+ "cell_type": "code",
2142
+ "execution_count": null,
2143
+ "id": "892ba310",
2144
+ "metadata": {},
2145
+ "outputs": [],
2146
+ "source": []
2147
+ },
2148
+ {
2149
+ "cell_type": "markdown",
2150
+ "id": "3aa64d74",
2151
+ "metadata": {},
2152
+ "source": []
2153
+ },
2154
+ {
2155
+ "cell_type": "code",
2156
+ "execution_count": null,
2157
+ "id": "eed737e3",
2158
+ "metadata": {},
2159
+ "outputs": [
2160
+ {
2161
+ "name": "stderr",
2162
+ "output_type": "stream",
2163
+ "text": [
2164
+ "C:\\Users\\drmaatt\\AppData\\Local\\Temp\\ipykernel_47360\\2981320948.py:26: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
2165
+ " checkpoint = torch.load(save_path)\n"
2166
+ ]
2167
+ },
2168
+ {
2169
+ "name": "stdout",
2170
+ "output_type": "stream",
2171
+ "text": [
2172
+ "[Video Load] Elapsed time: 1.0888 seconds\n",
2173
+ "[Video Transformation] Elapsed time: 1.0897 seconds\n",
2174
+ "[Feature Extraction] Elapsed time: 3.5884 seconds\n",
2175
+ "[Featurn Engineering 1] Elapsed time: 0.0095 seconds\n",
2176
+ "[Featurn Engineering 2] Elapsed time: 0.0015 seconds\n",
2177
+ "[Prediction] Elapsed time: 0.0180 seconds\n",
2178
+ "Predicted pushups: 3\n"
2179
+ ]
2180
+ }
2181
+ ],
2182
+ "source": []
2183
  }
2184
  ],
2185
  "metadata": {