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 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 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): 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))