mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
fix race condition on model load via api
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'])):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user