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

View File

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

View File

@ -374,6 +374,7 @@ AnyModelConfig = Annotated[
AnyModelConfigValidator = TypeAdapter(AnyModelConfig)
class ModelConfigFactory(object):
"""Class for parsing config dicts into StableDiffusion Config obects."""

View File

@ -75,7 +75,7 @@ const ModelListItem = (props: ModelListItemProps) => {
return (
<Flex gap={2} alignItems="center" w="full">
<ModelImage image_url={model.cover_image} />
<ModelImage image_url={model.cover_image || ''} />
<Flex
as={Button}
isChecked={isSelected}

View File

@ -30,11 +30,10 @@ const ModelImageUpload = ({ model_key, model_image }: Props) => {
return;
}
setImage(URL.createObjectURL(file));
updateModelImage({ key: model_key, image: file })
.unwrap()
.then(() => {
setImage(URL.createObjectURL(file));
dispatch(
addToast(
makeToast({
@ -103,6 +102,7 @@ const ModelImageUpload = ({ model_key, model_image }: Props) => {
objectPosition="50% 50%"
height="100px"
width="100px"
minWidth="100px"
borderRadius="base"
/>
<IconButton