From 4f77aece7290af7dd5012786186197065ed9d3ac Mon Sep 17 00:00:00 2001 From: troyyyyy Date: Mon, 18 Dec 2023 17:28:19 +0800 Subject: [PATCH] [FIX] resolve some comments (cont.) --- examples/hwf/datasets/test.ipynb | 70 ------------------- examples/hwf/{hwf_example.ipynb => hwf.ipynb} | 35 ++-------- examples/hwf/requirements.txt | 1 + requirements.txt | 5 +- 4 files changed, 9 insertions(+), 102 deletions(-) delete mode 100644 examples/hwf/datasets/test.ipynb rename examples/hwf/{hwf_example.ipynb => hwf.ipynb} (69%) diff --git a/examples/hwf/datasets/test.ipynb b/examples/hwf/datasets/test.ipynb deleted file mode 100644 index f72a9e0..0000000 --- a/examples/hwf/datasets/test.ipynb +++ /dev/null @@ -1,70 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name '__file__' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mPIL\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Image\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtorchvision\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtransforms\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m transforms\n\u001b[0;32m---> 10\u001b[0m CURRENT_DIR \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mabspath(os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mdirname(\u001b[38;5;18;43m__file__\u001b[39;49m))\n\u001b[1;32m 12\u001b[0m img_transform \u001b[38;5;241m=\u001b[39m transforms\u001b[38;5;241m.\u001b[39mCompose([transforms\u001b[38;5;241m.\u001b[39mToTensor(), transforms\u001b[38;5;241m.\u001b[39mNormalize((\u001b[38;5;241m0.5\u001b[39m,), (\u001b[38;5;241m1\u001b[39m,))])\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mrequests\u001b[39;00m\n", - "\u001b[0;31mNameError\u001b[0m: name '__file__' is not defined" - ] - } - ], - "source": [ - "import json\n", - "import os\n", - "import requests\n", - "import os\n", - "import zipfile\n", - "\n", - "from PIL import Image\n", - "from torchvision.transforms import transforms\n", - "\n", - "CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))\n", - "\n", - "img_transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (1,))])\n", - "\n", - "import requests\n", - "import os\n", - "import zipfile\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "abl", - "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.8.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/examples/hwf/hwf_example.ipynb b/examples/hwf/hwf.ipynb similarity index 69% rename from examples/hwf/hwf_example.ipynb rename to examples/hwf/hwf.ipynb index fd2a62a..2928458 100644 --- a/examples/hwf/hwf_example.ipynb +++ b/examples/hwf/hwf.ipynb @@ -11,11 +11,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This example shows a simple implementation of Handwritten Formula, which was first introduced in [Li et al., 2020](https://arxiv.org/abs/2006.06649). In this task, the inputs are images of decimal formulas, and the outputs are their computed results.\n", - "\n", + "This example shows a simple implementation of [Handwritten Formula](https://arxiv.org/abs/2006.06649). In this task, xxx.\n", + "" ] }, { @@ -41,17 +41,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12/18 12:48:19 - abl - INFO - Abductive Learning on the HWF example.\n" - ] - } - ], + "outputs": [], "source": [ "# Initialize logger and print basic information\n", "print_log(\"Abductive Learning on the HWF example.\", logger=\"current\")\n", @@ -185,22 +177,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "FileNotFoundError", - "evalue": "[Errno 2] 没有那个文件或目录: '/home/huwc/ABL-Package/examples/hwf/datasets/data/expr_train.json'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "Input \u001b[0;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Get training and testing data\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m train_data \u001b[38;5;241m=\u001b[39m \u001b[43mget_dataset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtrain\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mget_pseudo_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 3\u001b[0m test_data \u001b[38;5;241m=\u001b[39m get_dataset(train\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, get_pseudo_label\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", - "File \u001b[0;32m~/ABL-Package/examples/hwf/datasets/get_dataset.py:21\u001b[0m, in \u001b[0;36mget_dataset\u001b[0;34m(train, get_pseudo_label)\u001b[0m\n\u001b[1;32m 19\u001b[0m Y \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 20\u001b[0m img_dir \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(CURRENT_DIR, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata/Handwritten_Math_Symbols/\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 21\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m f:\n\u001b[1;32m 22\u001b[0m data \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mload(f)\n\u001b[1;32m 23\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m idx \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(data)):\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] 没有那个文件或目录: '/home/huwc/ABL-Package/examples/hwf/datasets/data/expr_train.json'" - ] - } - ], + "outputs": [], "source": [ "# Get training and testing data\n", "train_data = get_dataset(train=True, get_pseudo_label=True)\n", diff --git a/examples/hwf/requirements.txt b/examples/hwf/requirements.txt index 023006c..11aaa3a 100644 --- a/examples/hwf/requirements.txt +++ b/examples/hwf/requirements.txt @@ -1 +1,2 @@ +abl gdown \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6aabef9..66e1a5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,8 +2,5 @@ numpy pyswip==0.2.9 torch torchvision -torchaudio zoopt -termcolor -openml -z3-solver \ No newline at end of file +termcolor \ No newline at end of file