-
Notifications
You must be signed in to change notification settings - Fork 10
/
predict.py
50 lines (37 loc) · 1.41 KB
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
predict.py
Usage: python predict.py {Input Video} {(optional) destination folder}
Takes in an input video file and runs it through the entire process and prdiction pipeline
Video file must be 1920 x 1080 @ 60FPS
Video should contin gameplay of Counter Strike: Global Offensive
"""
import os
import sys
import random
import subprocess
# Ensure that there is an input file
assert len(sys.argv) >= 2, "Requires path to input file"
inFile = sys.argv[1]
assert os.path.isfile(inFile), f'{inFile} isn\'t a valid file path'
dir = "temp"
delDir = True
# allow a specified output directory
if len(sys.argv) > 2:
dir = sys.argv[2]
assert os.path.isdir(dir), f'{dir} isn\'t a valid dirctory'
assert len(os.listdir(dir)) == 0, "folder must be empty"
delDir = False
# Make a new unique folder if none is specified
if delDir:
while os.path.isdir(dir):
dir = "temp" + str(random.randint(1,1000000))
os.mkdir(dir)
# Run auto clip to get clips in folder
print(f'python auto_clip.py \'{inFile}\' \'{dir}\' 1')
subprocess.run(['python', './auto_clip.py', inFile, dir, '1'])
# process clips from auto_clip with cnn to extract features
print('\n\n\n\n\nNow extracting features')
subprocess.run(['python', 'save_cnn_output.py', dir, dir])
# run extracted features through rnn to classify
print('\n\n\n\n\nNow Predicting value of cheats')
subprocess.run(['python', 'test_rnn.py', os.path.join(dir, 'clips.pt'), dir])