Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions requirements_win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PyQt5
opencv-contrib-python==4.1.2.30
paramiko
scp
pynput
numpy
tqdm
pillow
matplotlib
pandas
scipy
8 changes: 7 additions & 1 deletion ultimatelabeling/models/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ 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)
filename = os.path.splitext(base)[0]

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):
Expand Down
10 changes: 6 additions & 4 deletions ultimatelabeling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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))
Expand Down