update model dB

support .zip file model
This commit is contained in:
Dr.Lt.Data
2024-05-09 23:57:14 +09:00
parent 39e937e991
commit e941c75cee
4 changed files with 63 additions and 25 deletions

View File

@@ -508,7 +508,12 @@ def check_model_installed(json_obj):
item['installed'] = 'None'
if model_path is not None:
if os.path.exists(model_path):
if model_path.endswith('.zip'):
if os.path.exists(model_path[:-4]):
item['installed'] = 'True'
else:
item['installed'] = 'False'
elif os.path.exists(model_path):
item['installed'] = 'True'
else:
item['installed'] = 'False'
@@ -915,10 +920,17 @@ async def install_model(request):
model_url.startswith('https://github.com') or model_url.startswith('https://huggingface.co') or model_url.startswith('https://heibox.uni-heidelberg.de')):
model_dir = get_model_dir(json_data)
download_url(model_url, model_dir, filename=json_data['filename'])
if model_path.endswith('.zip'):
res = core.unzip(model_path)
else:
res = True
return web.json_response({}, content_type='application/json')
if res:
return web.json_response({}, content_type='application/json')
else:
res = download_url_with_agent(model_url, model_path)
if res and model_path.endswith('.zip'):
res = core.unzip(model_path)
else:
print(f"Model installation error: invalid model type - {json_data['type']}")
@@ -926,7 +938,6 @@ async def install_model(request):
return web.json_response({}, content_type='application/json')
except Exception as e:
print(f"[ERROR] {e}", file=sys.stderr)
pass
return web.Response(status=400)