From d0553779abb8685314b763adc41886cb12702202 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 7 Mar 2022 12:33:35 -0500 Subject: [PATCH] Bug Fix --- aiserver.py | 21 +++++++++------------ static/application.js | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/aiserver.py b/aiserver.py index d44ab824..0da4f2a2 100644 --- a/aiserver.py +++ b/aiserver.py @@ -827,11 +827,12 @@ def get_layer_count(model, directory=""): pass 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 generator vars.noai = False - set_aibusy(True) + if not initial_load: + set_aibusy(True) if gpu_layers is not None: args.breakmodel_gpulayers = gpu_layers # 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() final_startup() - set_aibusy(False) + if not initial_load: + set_aibusy(False) + # Set up Flask routes @app.route('/') @@ -3850,16 +3853,10 @@ def refresh_settings(): def set_aibusy(state): if(state): vars.aibusy = True - try: - emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}, broadcast=True) - except: - pass + emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}, broadcast=True) else: vars.aibusy = False - try: - emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) - except: - pass + emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) #==================================================================# # @@ -5248,7 +5245,7 @@ if __name__ == "__main__": #show_select_model_list() if vars.model == "" or vars.model is None: vars.model = "ReadOnly" - load_model() + load_model(initial_load=True) # Start Flask/SocketIO (Blocking, so this must be last method!) diff --git a/static/application.js b/static/application.js index 8c238a4f..5fafa672 100644 --- a/static/application.js +++ b/static/application.js @@ -1928,6 +1928,7 @@ $(document).ready(function(){ socket = io.connect(window.document.origin, {transports: ['polling', 'websocket'], closeOnBeforeunload: false}); socket.on('from_server', function(msg) { + //console.log(msg); if(msg.cmd == "connected") { // Connected to Server Actions 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)}; - console.log(message); socket.send(message); loadmodelcontent.html(""); hideLoadModelPopup();