mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
moved upload image field and added delete image functionality
This commit is contained in:
committed by
Kent Keirsey
parent
8a68355926
commit
239b1e8cc7
@ -292,6 +292,7 @@ async def get_model_image(
|
||||
"""Gets a full-resolution image file"""
|
||||
|
||||
try:
|
||||
# still need to handle this gracefully when path doesnt exist instead of throwing error
|
||||
path = ApiDependencies.invoker.services.model_images.get_path(key + ".png")
|
||||
|
||||
if not path:
|
||||
@ -308,22 +309,6 @@ async def get_model_image(
|
||||
except Exception:
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
|
||||
# async def get_model_image(
|
||||
# key: Annotated[str, Path(description="Unique key of model")],
|
||||
# ) -> Optional[str]:
|
||||
# model_images = ApiDependencies.invoker.services.model_images
|
||||
# try:
|
||||
# url = model_images.get_url(key)
|
||||
|
||||
# if not url:
|
||||
# return None
|
||||
|
||||
# return url
|
||||
# except Exception:
|
||||
# raise HTTPException(status_code=404)
|
||||
|
||||
|
||||
@model_manager_router.patch(
|
||||
"/i/{key}/image",
|
||||
operation_id="update_model_image",
|
||||
@ -390,6 +375,28 @@ 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",
|
||||
responses={
|
||||
204: {"description": "Model image deleted successfully"},
|
||||
404: {"description": "Model image not found"},
|
||||
},
|
||||
status_code=204,
|
||||
)
|
||||
async def delete_model_image(
|
||||
key: str = Path(description="Unique key of model image to remove from model_images directory."),
|
||||
) -> None:
|
||||
logger = ApiDependencies.invoker.services.logger
|
||||
model_images = ApiDependencies.invoker.services.model_images
|
||||
try:
|
||||
model_images.delete(key)
|
||||
logger.info(f"Deleted model image: {key}")
|
||||
return
|
||||
except UnknownModelException as e:
|
||||
logger.error(str(e))
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
|
||||
# @model_manager_router.post(
|
||||
# "/i/",
|
||||
|
Reference in New Issue
Block a user