-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunme.py
More file actions
executable file
·137 lines (102 loc) · 3.57 KB
/
runme.py
File metadata and controls
executable file
·137 lines (102 loc) · 3.57 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import config
from ext import cls
def main():
ctr = 1
while ctr:
inp = input(f'Select: \n\t1 Configure \n\t2 Train \n\t3 Interact \n\n > ')
cls()
if inp == '1':
list_config()
change_config()
elif inp == '2':
import train
train.main()
elif inp == '3':
import interact
interact.main()
elif inp == '0':
cls()
break
cls()
ctr +=1
def list_config():
print('Config Params:')
for i,e in enumerate(dir(config)):
print(f'\t{i} {e}')
def change_config():
print(
'''
Warning:
IF running parallel training, AND modifying Neural Params ,
code changes @ config.py ,(changes through runtime will not be seen.)
''')
while 1:
if (i := input('Enter param index: ')) == '':
break
else:
try:
index = int(i)
print(f'> {dir(config)[index]} = {getattr(config,dir(config)[index])}')
except:
try:
index = dir(config).index(i)
print(f'> {index} = {getattr(config,i)}')
except Exception as e:
print(f'Error: execution failed {e}')
continue
if (e := input('Enter param value: ')) != '':
try:
# exec(f'config.{dir(config)[index]} = {eval(e)}')
setattr(config, dir(config)[index],eval(e))
except Exception as e1:
try:
# exec(f'config.{dir(config)[index]} = {e}')
setattr(config, dir(config)[index], e)
except Exception as e2:
print(f'Error: execution failed {e1} & {e2}')
##
if __name__ == '__main__':
cls()
try:
import torch
import qiskit
import pretty_midi
import music21
import matplotlib
except:
print('Warning: one or more required pip packages cannot be found, proceeding with installation..')
from os import system
try:
from torch import __version__ as v
if v != '1.5.0':
if input(f'Warning: torch version {v} found, but strictly requires 1.5.0 to run, \nproceed with the switch ? (you can always run pip update torch later) (y/n): ').lower() == 'y':
system('pip -y uninstall torch')
system('pip3 -y uninstall torch')
assert None
except:
print('installing torch..')
system('pip install torch==1.5.0')
system('pip3 install torch==1.5.0')
try: import qiskit
except:
print('installing qiskit..')
system('pip install qiskit')
system('pip3 install qiskit')
try: import music21
except:
print('installing music21..')
system('pip install music21==5.7.2')
system('pip3 install music21==5.7.2')
try: import pretty_midi
except:
print('installing pretty-midi..')
system('pip install pretty_midi')
system('pip3 install pretty_midi')
try: import matplotlib
except:
print('installing matplotlib..')
system('pip install matplotlib')
system('pip3 install matplotlib')
# try: from qiskit import IBMQ; IBMQ.load_account()
# except: print('Warning: IBMQ not accessible, run offline only')
main()