From 80518209025e1bdc49d27b724804d60e514d6a8c Mon Sep 17 00:00:00 2001 From: mahieyin-rahmun Date: Sat, 17 Oct 2020 12:54:50 +0600 Subject: [PATCH 1/4] requirements.txt file for windows --- requirements_win.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 requirements_win.txt diff --git a/requirements_win.txt b/requirements_win.txt new file mode 100644 index 0000000..9ad2994 --- /dev/null +++ b/requirements_win.txt @@ -0,0 +1,11 @@ +PyQt5 +opencv-contrib-python==4.1.2.30 +paramiko +scp +pynput +numpy +tqdm +pillow +matplotlib +pandas +scipy \ No newline at end of file From 60e4a7d672c133975a84fea043e9b9af1362e04e Mon Sep 17 00:00:00 2001 From: mahieyin-rahmun Date: Sat, 17 Oct 2020 12:56:20 +0600 Subject: [PATCH 2/4] added helper function to know if the platform is windows --- ultimatelabeling/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ultimatelabeling/utils.py b/ultimatelabeling/utils.py index 9cd1b67..e335abe 100644 --- a/ultimatelabeling/utils.py +++ b/ultimatelabeling/utils.py @@ -15,6 +15,10 @@ [2, 4], [3, 5], [4, 6], [5, 7]] +def is_platform_windows(): + from sys import platform + return platform == "win32" + def get_color(id): np.random.seed(id) return tuple(map(int, np.random.choice(range(256), size=3))) @@ -123,11 +127,9 @@ def subdivide_bbox(bbox): def convert_video_to_frames(video_file, output_folder): subprocess.check_call(['/bin/bash', 'extract_all.sh', video_file, output_folder]) -def convert_video_to_frames_opencv(video_file, output_folder): +def convert_video_to_frames_opencv(video_file, output_folder, MAX_FRAMES = 1000): if not os.path.exists(output_folder): - os.makedirs(output_folder) - - MAX_FRAMES = 1000 + os.makedirs(output_folder) vidcap = cv2.VideoCapture(video_file) nb_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT)) From c80bd86c56acd9d128b42b3bad26b711413e226a Mon Sep 17 00:00:00 2001 From: mahieyin-rahmun Date: Sat, 17 Oct 2020 12:57:39 +0600 Subject: [PATCH 3/4] updated code to use opencv frame extractor on windows --- ultimatelabeling/models/state.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ultimatelabeling/models/state.py b/ultimatelabeling/models/state.py index 020b70c..caef6ac 100644 --- a/ultimatelabeling/models/state.py +++ b/ultimatelabeling/models/state.py @@ -81,6 +81,7 @@ def find_videos(self): def check_raw_videos(self): files = glob.glob(os.path.join(DATA_DIR, "*.mp4")) files.extend(glob.glob(os.path.join(DATA_DIR, "*.mov"))) + files.extend(glob.glob(os.path.join(DATA_DIR, "*.avi"))) # support for AVI files for file in files: base = os.path.basename(file) @@ -88,7 +89,12 @@ def check_raw_videos(self): if filename not in self.video_list: print("Extracting video {}...".format(base)) - utils.convert_video_to_frames(file, os.path.join(DATA_DIR, filename)) + if utils.is_platform_windows(): + # perhaps it is possible to use opencv on all platforms for uniformity? + utils.convert_video_to_frames_opencv(file, os.path.join(DATA_DIR, filename)) + else: + utils.convert_video_to_frames(file, os.path.join(DATA_DIR, filename)) + self.video_list = self.find_videos() def update_file_names(self): From c007291dc0730ba3d903ab2b6cd47b2f51af7d66 Mon Sep 17 00:00:00 2001 From: mahieyin-rahmun Date: Sat, 17 Oct 2020 12:58:10 +0600 Subject: [PATCH 4/4] added installation instructions on Windows --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2f952c5..b52c81a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,19 @@ Otherwise, just install the requirements on your main Python environment using ` pip install -r requirements ``` +## Special note on Windows 10: +On Windows 10, installing `torch` directly from `requirements.txt` file raises the error `ModuleNotFoundError: No module named 'tools.nnwrap'`. To circumvent this, use the `requirements_win.txt` file on Windows. + +```bash +pip install -r requirements_win.txt +``` + +Then, head over to [Pytorch website](https://pytorch.org/get-started/locally/), and select the appropriate version that you want to install (CPU-only/GPU) and run the command that the website displays to you. For example, to install the CPU-only version, you would run: + +```bash +pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html +``` + Finally, open the GUI using: ```bash python -m ultimatelabeling.main