This commit is contained in:
ebolam 2022-03-07 12:33:35 -05:00
parent 6a08fe2f10
commit d0553779ab
2 changed files with 10 additions and 13 deletions

View File

@ -827,11 +827,12 @@ def get_layer_count(model, directory=""):
pass pass
return layers return layers
def load_model(use_gpu=True, key='', gpu_layers=None): def load_model(use_gpu=True, key='', gpu_layers=None, initial_load=False):
global model global model
global generator global generator
vars.noai = False vars.noai = False
set_aibusy(True) if not initial_load:
set_aibusy(True)
if gpu_layers is not None: if gpu_layers is not None:
args.breakmodel_gpulayers = gpu_layers args.breakmodel_gpulayers = gpu_layers
# If transformers model was selected & GPU available, ask to use CPU or GPU # If transformers model was selected & GPU available, ask to use CPU or GPU
@ -1587,7 +1588,9 @@ def load_model(use_gpu=True, key='', gpu_layers=None):
load_lua_scripts() load_lua_scripts()
final_startup() final_startup()
set_aibusy(False) if not initial_load:
set_aibusy(False)
# Set up Flask routes # Set up Flask routes
@app.route('/') @app.route('/')
@ -3850,16 +3853,10 @@ def refresh_settings():
def set_aibusy(state): def set_aibusy(state):
if(state): if(state):
vars.aibusy = True vars.aibusy = True
try: emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}, broadcast=True)
emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}, broadcast=True)
except:
pass
else: else:
vars.aibusy = False vars.aibusy = False
try: emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True)
emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True)
except:
pass
#==================================================================# #==================================================================#
# #
@ -5248,7 +5245,7 @@ if __name__ == "__main__":
#show_select_model_list() #show_select_model_list()
if vars.model == "" or vars.model is None: if vars.model == "" or vars.model is None:
vars.model = "ReadOnly" vars.model = "ReadOnly"
load_model() load_model(initial_load=True)
# Start Flask/SocketIO (Blocking, so this must be last method!) # Start Flask/SocketIO (Blocking, so this must be last method!)

View File

@ -1928,6 +1928,7 @@ $(document).ready(function(){
socket = io.connect(window.document.origin, {transports: ['polling', 'websocket'], closeOnBeforeunload: false}); socket = io.connect(window.document.origin, {transports: ['polling', 'websocket'], closeOnBeforeunload: false});
socket.on('from_server', function(msg) { socket.on('from_server', function(msg) {
//console.log(msg);
if(msg.cmd == "connected") { if(msg.cmd == "connected") {
// Connected to Server Actions // Connected to Server Actions
sman_allow_delete = msg.hasOwnProperty("smandelete") && msg.smandelete; sman_allow_delete = msg.hasOwnProperty("smandelete") && msg.smandelete;
@ -2642,7 +2643,6 @@ $(document).ready(function(){
} }
} }
message = {'cmd': 'load_model', 'use_gpu': $('#use_gpu')[0].checked, 'key': $('#modelkey')[0].value, 'gpu_layers': gpu_layers.slice(0, -1)}; message = {'cmd': 'load_model', 'use_gpu': $('#use_gpu')[0].checked, 'key': $('#modelkey')[0].value, 'gpu_layers': gpu_layers.slice(0, -1)};
console.log(message);
socket.send(message); socket.send(message);
loadmodelcontent.html(""); loadmodelcontent.html("");
hideLoadModelPopup(); hideLoadModelPopup();