From 9f95515339f347c676a6e4a6de19c19adbe382db Mon Sep 17 00:00:00 2001 From: Chakkrit Date: Thu, 12 May 2022 00:14:50 +0700 Subject: [PATCH] Add version in requirements.txt --- README.md | 8 +++++--- data.py | 2 -- download.py | 30 +++--------------------------- main.py | 4 ++-- main_ensemble.py | 4 ++-- requirements.txt | 18 ++++++++++-------- 6 files changed, 22 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 237280c..3f00603 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ This offical implementation of PKD (Pseudo Knowledge Distillation) from On-devic **This code is based on the implementation of [EML-NET-Saliency](https://github.com/SenJia/EML-NET-Saliency), [SimpleNet](https://github.com/samyak0210/saliency), [MSI-Net](https://github.com/alexanderkroner/saliency), and [EEEA-Net](https://github.com/chakkritte/EEEA-Net).** ## Prerequisite for server - - Tested on Ubuntu OS version 20.04.x + - Tested on Ubuntu OS version 20.04.4 LTS + - Tested on Python 3.6.13 + - Tested on CUDA 11.6 - Tested on PyTorch 1.10.2 and TorchVision 0.11.3 - Tested on NVIDIA V100 32 GB (four cards) @@ -55,7 +57,7 @@ PKD ### Creating new environments ``` -conda create -n pkd python=3.6 +conda create -n pkd python=3.6.13 conda activate pkd conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch ``` @@ -63,7 +65,7 @@ conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch ### Install Requirements ``` -pip install -r requirements.txt +pip install -r requirements.txt --no-cache-dir ``` ## Usage diff --git a/data.py b/data.py index 376afb9..c1e8eb2 100644 --- a/data.py +++ b/data.py @@ -9,8 +9,6 @@ from scipy import io import random -# seed_everything(42, workers=True) - def _get_file_list(data_path): """This function detects all image files within the specified parent directory for either training or testing. The path content cannot diff --git a/download.py b/download.py index 4d988cc..c743b2c 100644 --- a/download.py +++ b/download.py @@ -8,6 +8,7 @@ from matplotlib.pyplot import imread, imsave from scipy.io import loadmat from scipy.ndimage import gaussian_filter +import gdown def download_salicon(data_path): """Downloads the SALICON dataset. Three folders are then created that @@ -41,15 +42,7 @@ def download_salicon(data_path): session = requests.Session() for count, url in enumerate(urls): - response = session.get(url, params={"id": id}, stream=True) - token = _get_confirm_token(response) - - if token: - params = {"id": id, "confirm": token} - response = session.get(url, params=params, stream=True) - - _save_response_content(response, data_path + "tmp.zip") - + gdown.download(url, data_path + "tmp.zip", quiet=False) with zipfile.ZipFile(data_path + "tmp.zip", "r") as zip_ref: for file in zip_ref.namelist(): if "test" not in file: @@ -417,21 +410,4 @@ def download_fiwi(data_path): os.remove(data_path + "tmp.zip") - print("done!", flush=True) - - -def _get_confirm_token(response): - for key, value in response.cookies.items(): - if key.startswith("download_warning"): - return value - - return None - -def _save_response_content(response, file_path): - chunk_size = 32768 - - with open(file_path, "wb") as data: - for chunk in response.iter_content(chunk_size): - if chunk: - data.write(chunk) - + print("done!", flush=True) \ No newline at end of file diff --git a/main.py b/main.py index e5923b7..e6a9440 100644 --- a/main.py +++ b/main.py @@ -14,10 +14,10 @@ parser = ArgumentParser() parser.add_argument("--learning_rate", type=float, default=0.0001) parser.add_argument("--batch_size", type=int, default=64) -parser.add_argument("--dataset_dir", type=str, default="/home/chakkritt/proj/datasets/") +parser.add_argument("--dataset_dir", type=str, default="data/") parser.add_argument('--input_size_h',default=384, type=int) parser.add_argument('--input_size_w',default=384, type=int) -parser.add_argument('--no_workers',default=16, type=int) +parser.add_argument('--no_workers',default=8, type=int) parser.add_argument('--no_epochs',default=10, type=int) parser.add_argument('--log_interval',default=20, type=int) parser.add_argument('--lr_sched',default=True, type=bool) diff --git a/main_ensemble.py b/main_ensemble.py index 97c48eb..302a5d0 100644 --- a/main_ensemble.py +++ b/main_ensemble.py @@ -14,10 +14,10 @@ parser = ArgumentParser() parser.add_argument("--learning_rate", type=float, default=0.0001) parser.add_argument("--batch_size", type=int, default=64) -parser.add_argument("--dataset_dir", type=str, default="/home/mllab/proj/2021/supernet/data/") +parser.add_argument("--dataset_dir", type=str, default="data/") parser.add_argument('--input_size_h',default=256, type=int) parser.add_argument('--input_size_w',default=256, type=int) -parser.add_argument('--no_workers',default=16, type=int) +parser.add_argument('--no_workers',default=8, type=int) parser.add_argument('--no_epochs',default=10, type=int) parser.add_argument('--log_interval',default=20, type=int) parser.add_argument('--lr_sched',default=True, type=bool) diff --git a/requirements.txt b/requirements.txt index c5417a5..168d79d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,10 @@ -darmo -timm -kornia -opencv-python -ptflops -h5py -scikit-image -requests \ No newline at end of file +darmo==0.1.12 +timm==0.4.12 +kornia==0.6.4 +opencv-python==4.5.5.64 +ptflops==0.6.9 +h5py==3.1.0 +scikit-image==0.17.2 +requests==2.27.1 +matplotlib==3.3.4 +gdown==4.4.0 \ No newline at end of file