mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
cleanup
This commit is contained in:
committed by
Kent Keirsey
parent
8df02623f2
commit
4af5a09a68
@ -287,7 +287,7 @@ async def update_model_record(
|
||||
"description": "The model image was fetched successfully",
|
||||
},
|
||||
400: {"description": "Bad request"},
|
||||
404: {"description": "The model image could not be found"}
|
||||
404: {"description": "The model image could not be found"},
|
||||
},
|
||||
status_code=200,
|
||||
)
|
||||
@ -310,6 +310,7 @@ async def get_model_image(
|
||||
except Exception:
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
|
||||
@model_manager_router.patch(
|
||||
"/i/{key}/image",
|
||||
operation_id="update_model_image",
|
||||
@ -376,6 +377,7 @@ async def delete_model(
|
||||
logger.error(str(e))
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
|
||||
@model_manager_router.delete(
|
||||
"/i/{key}/image",
|
||||
operation_id="delete_model_image",
|
||||
|
@ -23,8 +23,9 @@ class ModelImagesService(ModelImagesBase):
|
||||
__invoker: Invoker
|
||||
|
||||
def __init__(self, model_images_folder: Union[str, Path]):
|
||||
|
||||
self.__model_images_folder: Path = model_images_folder if isinstance(model_images_folder, Path) else Path(model_images_folder)
|
||||
self.__model_images_folder: Path = (
|
||||
model_images_folder if isinstance(model_images_folder, Path) else Path(model_images_folder)
|
||||
)
|
||||
# Validate required folders at launch
|
||||
self.__validate_storage_folders()
|
||||
|
||||
@ -50,7 +51,7 @@ class ModelImagesService(ModelImagesBase):
|
||||
) -> None:
|
||||
try:
|
||||
self.__validate_storage_folders()
|
||||
image_path = self.__model_images_folder / (model_key + '.webp')
|
||||
image_path = self.__model_images_folder / (model_key + ".webp")
|
||||
image = make_thumbnail(image, 256)
|
||||
|
||||
image.save(image_path, format="webp")
|
||||
@ -59,7 +60,7 @@ class ModelImagesService(ModelImagesBase):
|
||||
raise ModelImageFileSaveException from e
|
||||
|
||||
def get_path(self, model_key: str) -> Path:
|
||||
path = self.__model_images_folder / (model_key + '.webp')
|
||||
path = self.__model_images_folder / (model_key + ".webp")
|
||||
|
||||
return path
|
||||
|
||||
@ -75,7 +76,7 @@ class ModelImagesService(ModelImagesBase):
|
||||
path = self.get_path(model_key)
|
||||
|
||||
if not self.validate_path(path):
|
||||
raise ModelImageFileNotFoundException
|
||||
raise ModelImageFileNotFoundException
|
||||
|
||||
send2trash(path)
|
||||
|
||||
|
Reference in New Issue
Block a user