-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·115 lines (98 loc) · 4.73 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#-----------------------------------------------------------------------------------------#
#Quick sending code to github
import os
import sys
if(sys.argv[1]=="-g"):
os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
os.system('git add -A')
os.system('git commit -am "-"')
os.system('git push')
exit()
if(sys.argv[1]=="-d"):
os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
fnam = sys.argv[2]
if not(os.path.exists("out/")):
os.mkdir("out/")
os.system("scp proc2:~/Files/codet/out/"+str(fnam)+" "+"out/"+str(fnam))
exit()
#-----------------------------------------------------------------------------------------#
from header import *
#-----------------------------------------------------------------------------------------#
def quick_test1():
video_points = []
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/0.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/1.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/2.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/3.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/4.jpg"))
video_fnam = "/srv/storage/datasets/Diognei/Video/MSHP/Verlab1.mp4"
evaluator.metrics.calc_fidscore(video_points,video_fnam)
def quick_test2():
video_points = []
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/0.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/1.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/2.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/3.jpg"))
video_points.append((0,0,0,0,0,"/srv/storage/datasets/Diognei/Cache/video/Verlab1/frames/4.jpg"))
stab = evaluator.metrics.calc_vidshak(video_points)
print(stab)
#-----------------------------------------------------------------------------------------#
#Main function
def main():
print("Initializing system...")
use_gpu = True if(torch.cuda.is_available()) else False
if not(use_gpu):
print("Note: GPU not available, will use CPU!")
if(task in ["clean","train","test"]):
learning.trainer.run(task,version_name,use_gpu)
elif(task=="save_best"):
utils.save_model_as_main(version_name)
elif(task=="prepare_deam"):
c = utils.str2bool(input("Clean? (y/n) "))
nc = int(input("Num classes: "))
ud = utils.str2bool(input("Undersampling: "))
dataprep.deam.run(num_classes=nc,clean=c,undsamp=ud)
elif(task=="prepare_mvso"):
dataprep.mvso.run()
elif(task=="prepare_other"):
dataprep.other.run()
elif(task=="predict_audio"):
write_video = False if render_video==0 else True
profgen1 = combiner.profgen.profgen("audio",64,song_filename,write_video,use_gpu)
profgen1.plot_emotion_profile(render_video)
elif(task=="predict_video"):
write_video = False if render_video==0 else True
profgen1 = combiner.profgen.profgen("video", 4,video_filename,write_video,use_gpu)
profgen1.plot_emotion_profile(render_video)
elif(task=="predict_images"):
write_video = False if render_video==0 else True
profgen1 = combiner.profgen.profgen("image", 4,list_filename,write_video,use_gpu)
profgen1.plot_emotion_profile(render_video)
elif(task=="make_hyperlapse"):
result_mode = "score" if render_video==0 else "animation"
opt_method = optim_method
combiner.hypmaker.make_hyperlapse(video_filename,song_filename,opt_method,result_mode)
elif(task=="run_experiments"):
clean_level = int(clean_exps)
evaluator.runner.run_experiments(video_filename,clean_level)
elif(task=="create_full_table"):
evaluator.runner.create_full_table()
elif(task=="quick_test"):
quick_test2()
elif(task=="clean_out_dir"):
print("Cleaning out dir...")
if(os.path.exists(out_dir)):
shutil.rmtree(out_dir)
elif(task=="run_basecomp"):
other.basecomp.run(video_filename,optim_method)
elif(task=="gen_qualplots"):
evaluator.plotter.run()
elif(task=="gen_suppmat"):
other.suppmat.run()
else:
print("Undefined task "+str(task))
utils.clear_pycache()
#-----------------------------------------------------------------------------------------#
if __name__ == "__main__":
main()
#-----------------------------------------------------------------------------------------#