This commit is contained in:
Jennifer Player 2024-03-06 14:18:21 -05:00 committed by Kent Keirsey
parent 8df02623f2
commit 4af5a09a68
5 changed files with 13 additions and 9 deletions

View File

@ -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",

View File

@ -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

View File

@ -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."""

View File

@ -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}

View File

@ -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