Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
xie river committed Apr 12, 2023
1 parent e3d2139 commit 02e3d02
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
24 changes: 24 additions & 0 deletions modules/shared.py
Expand Up @@ -337,6 +337,30 @@ def pop_least_ref_model(self):
cn_models_Ref = ModelsRef()
lora_models_Ref = ModelsRef()

def de_register_model(model_name,mode):
models_Ref = sd_models_Ref
if mode == 'sd' :
models_Ref = sd_models_Ref
elif mode == 'cn':
models_Ref = cn_models_Ref
elif mode == 'lora':
models_Ref = lora_models_Ref
models_Ref.remove_model_ref(model_name)
print (f'---de_register_{mode}_model({model_name})---models_Ref({models_Ref.get_models_ref_dict()})----')
if 'endpoint_name' in os.environ:
api_endpoint = os.environ['api_endpoint']
endpoint_name = os.environ['endpoint_name']
data = {
"module":mode,
"model_name": model_name,
"endpoint_name": endpoint_name
}
response = requests.delete(url=f'{api_endpoint}/sd/models', json=data)
# Check if the request was successful
if response.status_code == requests.codes.ok:
print(f"{model_name} deleted successfully!")
else:
print(f"Error deleting {model_name}: ", response.text)
#end by River

class OptionInfo:
Expand Down
27 changes: 1 addition & 26 deletions webui.py
Expand Up @@ -39,7 +39,7 @@

import modules.ui
from modules import modelloader
from modules.shared import cmd_opts, opts, sd_model,syncLock
from modules.shared import cmd_opts, opts, sd_model,syncLock,de_register_model
import modules.hypernetworks.hypernetwork
import boto3
import threading
Expand Down Expand Up @@ -548,31 +548,6 @@ def register_cn_models(cn_models_dir):
response = requests.post(url=f'{api_endpoint}/sd/models', json=inputs, params=params)
print(response)

def de_register_model(model_name,mode):
models_Ref = sd_models_Ref
if mode == 'sd' :
models_Ref = sd_models_Ref
elif mode == 'cn':
models_Ref = cn_models_Ref
elif mode == 'lora':
models_Ref = lora_models_Ref
models_Ref.remove_model_ref(model_name)
print (f'---de_register_{mode}_model({model_name})---models_Ref({models_Ref.get_models_ref_dict()})----')
if 'endpoint_name' in os.environ:
api_endpoint = os.environ['api_endpoint']
endpoint_name = os.environ['endpoint_name']
data = {
"module":mode,
"model_name": model_name,
"endpoint_name": endpoint_name
}
response = requests.delete(url=f'{api_endpoint}/sd/models', json=data)
# Check if the request was successful
if response.status_code == requests.codes.ok:
print(f"{model_name} deleted successfully!")
else:
print(f"Error deleting {model_name}: ", response.text)

def webui():
launch_api = cmd_opts.api

Expand Down

0 comments on commit 02e3d02

Please sign in to comment.