mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
cleanup
This commit is contained in:
parent
8df02623f2
commit
4af5a09a68
@ -287,7 +287,7 @@ async def update_model_record(
|
|||||||
"description": "The model image was fetched successfully",
|
"description": "The model image was fetched successfully",
|
||||||
},
|
},
|
||||||
400: {"description": "Bad request"},
|
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,
|
status_code=200,
|
||||||
)
|
)
|
||||||
@ -310,6 +310,7 @@ async def get_model_image(
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
|
|
||||||
@model_manager_router.patch(
|
@model_manager_router.patch(
|
||||||
"/i/{key}/image",
|
"/i/{key}/image",
|
||||||
operation_id="update_model_image",
|
operation_id="update_model_image",
|
||||||
@ -376,6 +377,7 @@ async def delete_model(
|
|||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
raise HTTPException(status_code=404, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
@model_manager_router.delete(
|
@model_manager_router.delete(
|
||||||
"/i/{key}/image",
|
"/i/{key}/image",
|
||||||
operation_id="delete_model_image",
|
operation_id="delete_model_image",
|
||||||
|
@ -23,8 +23,9 @@ class ModelImagesService(ModelImagesBase):
|
|||||||
__invoker: Invoker
|
__invoker: Invoker
|
||||||
|
|
||||||
def __init__(self, model_images_folder: Union[str, Path]):
|
def __init__(self, model_images_folder: Union[str, Path]):
|
||||||
|
self.__model_images_folder: Path = (
|
||||||
self.__model_images_folder: Path = model_images_folder if isinstance(model_images_folder, Path) else Path(model_images_folder)
|
model_images_folder if isinstance(model_images_folder, Path) else Path(model_images_folder)
|
||||||
|
)
|
||||||
# Validate required folders at launch
|
# Validate required folders at launch
|
||||||
self.__validate_storage_folders()
|
self.__validate_storage_folders()
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class ModelImagesService(ModelImagesBase):
|
|||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
self.__validate_storage_folders()
|
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 = make_thumbnail(image, 256)
|
||||||
|
|
||||||
image.save(image_path, format="webp")
|
image.save(image_path, format="webp")
|
||||||
@ -59,7 +60,7 @@ class ModelImagesService(ModelImagesBase):
|
|||||||
raise ModelImageFileSaveException from e
|
raise ModelImageFileSaveException from e
|
||||||
|
|
||||||
def get_path(self, model_key: str) -> Path:
|
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
|
return path
|
||||||
|
|
||||||
|
@ -374,6 +374,7 @@ AnyModelConfig = Annotated[
|
|||||||
|
|
||||||
AnyModelConfigValidator = TypeAdapter(AnyModelConfig)
|
AnyModelConfigValidator = TypeAdapter(AnyModelConfig)
|
||||||
|
|
||||||
|
|
||||||
class ModelConfigFactory(object):
|
class ModelConfigFactory(object):
|
||||||
"""Class for parsing config dicts into StableDiffusion Config obects."""
|
"""Class for parsing config dicts into StableDiffusion Config obects."""
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ const ModelListItem = (props: ModelListItemProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex gap={2} alignItems="center" w="full">
|
<Flex gap={2} alignItems="center" w="full">
|
||||||
<ModelImage image_url={model.cover_image} />
|
<ModelImage image_url={model.cover_image || ''} />
|
||||||
<Flex
|
<Flex
|
||||||
as={Button}
|
as={Button}
|
||||||
isChecked={isSelected}
|
isChecked={isSelected}
|
||||||
|
@ -30,11 +30,10 @@ const ModelImageUpload = ({ model_key, model_image }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage(URL.createObjectURL(file));
|
|
||||||
|
|
||||||
updateModelImage({ key: model_key, image: file })
|
updateModelImage({ key: model_key, image: file })
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
setImage(URL.createObjectURL(file));
|
||||||
dispatch(
|
dispatch(
|
||||||
addToast(
|
addToast(
|
||||||
makeToast({
|
makeToast({
|
||||||
@ -103,6 +102,7 @@ const ModelImageUpload = ({ model_key, model_image }: Props) => {
|
|||||||
objectPosition="50% 50%"
|
objectPosition="50% 50%"
|
||||||
height="100px"
|
height="100px"
|
||||||
width="100px"
|
width="100px"
|
||||||
|
minWidth="100px"
|
||||||
borderRadius="base"
|
borderRadius="base"
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
Loading…
Reference in New Issue
Block a user