fix race condition on model load via api

This commit is contained in:
Vladimir Mandic
2023-06-19 09:13:17 -04:00
parent f42553918b
commit 2345237844
3 changed files with 6 additions and 1 deletions
+2
View File
@@ -14,6 +14,8 @@ Stuff to be added...
- Import core repos
- Update `train.py` to use `interrogator`
- Update `train.py` to use `rembg`
- Create new train UI
- Create new Models UI
## Investigate
+3
View File
@@ -9,6 +9,7 @@ from PIL import Image
logging.basicConfig(level = logging.INFO, format = '%(asctime)s %(levelname)s: %(message)s')
log = logging.getLogger(__name__)
sd_url = "http://127.0.0.1:7860"
model = "realistic-vision-v13"
options = {
"prompt": "city at night",
"negative_prompt": "foggy, blurry",
@@ -33,6 +34,8 @@ def post(endpoint: str, dct: dict = None):
def generate(num: int = 0):
log.info(f'sending generate request: {num+1} {options}')
if model is not None:
post('/sdapi/v1/options', { 'sd_model_checkpoint': model })
data = post('/sdapi/v1/txt2img', options)
if 'images' in data:
for i in range(len(data['images'])):
+1 -1
View File
@@ -617,7 +617,7 @@ def reload_model_weights(sd_model=None, info=None, reuse_dict=False):
current_checkpoint_info = None
else:
current_checkpoint_info = sd_model.sd_checkpoint_info
if checkpoint_info is not None and sd_model.sd_model_checkpoint == checkpoint_info.filename:
if checkpoint_info is not None and current_checkpoint_info.filename == checkpoint_info.filename:
return
if shared.cmd_opts.lowvram or shared.cmd_opts.medvram:
lowvram.send_everything_to_cpu()