Repository navigation
Expand file tree
/
Copy pathmodelManager.py
More file actions
61 lines (39 loc) · 1.45 KB
/
Copy pathmodelManager.py
File metadata and controls
61 lines (39 loc) · 1.45 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
import os
#######################################
## Asking user about Loading a Model ##
#######################################
def AskLoadModel() -> list[str,bool]:
"""Asks user whether or not to load a saved model
Returns:
list[str, bool]: path to the saved model if load is desired, and whether or not it's a load
"""
user_in = input('Load saved model? [y/N]')
if user_in in ['yes', 'Yes', 'y', 'Y']:
# If user wishes to load a saved model
return _query_saved_model(), True
elif user_in in ['No', 'no', 'N', 'n', '']:
# If user input is 'no' (creates new model)
return _query_new_model_path(), False
else:
# If input is invalid
return AskLoadModel()
def _query_saved_model():
saved_models = _list_saved_models()
# List saved models
for path in saved_models:
print(path)
user_in = input('Choose a model to load ("Cancel" to cancel): ')
if user_in in saved_models:
return user_in
elif user_in in ['Cancel', 'cancel']:
return None
else:
print('INVALID SELECTION')
return _query_saved_model()
def _list_saved_models() -> list:
return os.listdir('model')
##########################################
## Asking user about Saving a new Model ##
##########################################
def _query_new_model_path() -> str:
return input('Name of new model: ')