mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-06-07 14:17:09 -04:00
sd_api_pictures model reload fix (#6720)
This commit is contained in:
parent
edbe0af647
commit
b54bf359bf
1 changed files with 6 additions and 3 deletions
|
@ -11,7 +11,7 @@ import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from modules import shared
|
from modules import shared
|
||||||
from modules.models import reload_model, unload_model
|
from modules.models import load_model, unload_model
|
||||||
from modules.ui import create_refresh_button
|
from modules.ui import create_refresh_button
|
||||||
|
|
||||||
torch._C._jit_set_profiling_mode(False)
|
torch._C._jit_set_profiling_mode(False)
|
||||||
|
@ -38,7 +38,8 @@ params = {
|
||||||
'cfg_scale': 7,
|
'cfg_scale': 7,
|
||||||
'textgen_prefix': 'Please provide a detailed and vivid description of [subject]',
|
'textgen_prefix': 'Please provide a detailed and vivid description of [subject]',
|
||||||
'sd_checkpoint': ' ',
|
'sd_checkpoint': ' ',
|
||||||
'checkpoint_list': [" "]
|
'checkpoint_list': [" "],
|
||||||
|
'last_model': ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ def give_VRAM_priority(actor):
|
||||||
global shared, params
|
global shared, params
|
||||||
|
|
||||||
if actor == 'SD':
|
if actor == 'SD':
|
||||||
|
params["last_model"] = shared.model_name
|
||||||
unload_model()
|
unload_model()
|
||||||
print("Requesting Auto1111 to re-load last checkpoint used...")
|
print("Requesting Auto1111 to re-load last checkpoint used...")
|
||||||
response = requests.post(url=f'{params["address"]}/sdapi/v1/reload-checkpoint', json='')
|
response = requests.post(url=f'{params["address"]}/sdapi/v1/reload-checkpoint', json='')
|
||||||
|
@ -55,7 +57,8 @@ def give_VRAM_priority(actor):
|
||||||
print("Requesting Auto1111 to vacate VRAM...")
|
print("Requesting Auto1111 to vacate VRAM...")
|
||||||
response = requests.post(url=f'{params["address"]}/sdapi/v1/unload-checkpoint', json='')
|
response = requests.post(url=f'{params["address"]}/sdapi/v1/unload-checkpoint', json='')
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
reload_model()
|
if params["last_model"]:
|
||||||
|
shared.model, shared.tokenizer = load_model(params["last_model"])
|
||||||
|
|
||||||
elif actor == 'set':
|
elif actor == 'set':
|
||||||
print("VRAM mangement activated -- requesting Auto1111 to vacate VRAM...")
|
print("VRAM mangement activated -- requesting Auto1111 to vacate VRAM...")
|
||||||
|
|
Loading…
Add table
Reference in a new issue