Skip to content

Commit

Permalink
Add Kaggle notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-snd committed Sep 9, 2022
1 parent 9531129 commit 85df74a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions notebooks/TRecover-train-kaggle.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div align=\"center\">\n <h2 align=\"center\">Welcome to <a href=\"https://alex-snd.github.io/TRecover/\">Text Recovery Project</a> 👋 </h2>\n</div>\n<br>\n<div align=\"center\">\n <a href=\"https://wandb.ai/snd/TRecover?workspace=user-snd\">\n <img src=\"https://badgen.net/badge/icon/Track%20global%20train%20progress%20in%20W&B/48466D?icon=https://github.com/alex-snd/TRecover/blob/assets/wandb_dots_logo.svg?raw=true&label&scale=1.25\" alt=\"Track global train progress in W&B\"/>\n </a>\n</div>","metadata":{}},{"cell_type":"markdown","source":"## 🧱 Installing dependencies. This may take a few minutes.","metadata":{}},{"cell_type":"code","source":"import os\nimport sys\nimport time\nimport warnings\nfrom datetime import datetime\nfrom pathlib import Path \n\nfrom IPython.display import clear_output\n\nwarnings.filterwarnings('ignore')\n\nif Path('/kaggle/working').exists():\n os.chdir('/kaggle/working')\n\n! sudo apt update\n! sudo apt install python3.8 python3-pip -y\n\n! wget https://bootstrap.pypa.io/get-pip.py\n! sudo python3.8 get-pip.py\n\n! python3.8 -m pip install --upgrade pip setuptools\n\n! sudo update-alternatives --install //opt/conda/bin/python python /opt/conda/bin/python3.7 1\n! sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2\n\nif os.environ.get(\"PYTHONPATH\"):\n os.environ[\"PYTHONPATH\"] = f\"{os.environ['PYTHONPATH']}:/usr/lib/python3.8/site-packages:/usr/bin\"\nelse:\n os.environ[\"PYTHONPATH\"] = \"/usr/lib/python3.8/site-packages:/usr/bin\"\n\nbase_project_path = Path(\"TRecover\").absolute()\n\nif base_project_path.exists():\n date = datetime.now()\n new_project_path = Path(f\"TRecover-{date.month:0>2}-{date.day:0>2}-{date.hour:0>2}-{date.minute:0>2}\").absolute()\n\n base_project_path.rename(new_project_path)\n project_path = new_project_path\nelse:\n project_path = base_project_path\n\n! git clone https://github.com/alex-snd/TRecover.git\n\n! python3.8 -m pip install \"TRecover/.[collab]\"\n\nos.chdir(project_path.absolute())\n\n! trecover init --base {base_project_path} --relocate\n\nos.chdir(base_project_path)\n\nimport torch\n\n\nclear_output()","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-09-08T15:31:32.775761Z","iopub.execute_input":"2022-09-08T15:31:32.776420Z","iopub.status.idle":"2022-09-08T15:34:03.799964Z","shell.execute_reply.started":"2022-09-08T15:31:32.776341Z","shell.execute_reply":"2022-09-08T15:34:03.798971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 🗃️ Loading training data","metadata":{}},{"cell_type":"code","source":"! trecover download data\n\nclear_output()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T15:34:03.801753Z","iopub.execute_input":"2022-09-08T15:34:03.802700Z","iopub.status.idle":"2022-09-08T15:34:35.563742Z","shell.execute_reply.started":"2022-09-08T15:34:03.802655Z","shell.execute_reply":"2022-09-08T15:34:35.562481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 💪 Model training","metadata":{}},{"cell_type":"code","source":"! trecover collab train --client-mode --sync-args --batch-size 4 --bandwidth 500 --n-workers 1 --backup-every-step 1","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}

0 comments on commit 85df74a

Please sign in to comment.