From 7db1378e1a448197d444371fac8b4c329f514f9e Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Tue, 12 Mar 2024 14:26:26 +0100 Subject: [PATCH] fix(image-to-video): enhance error handling for width/height parameters This commit improves the error handling for the width and height parameters in the image-to-video pipeline. It ensures that a detailed JSON error response is returned when the width and/or height parameters are not divisible by 8, as required by the [StableVideoDiffusion](https://github.com/livepeer/ai-worker/blob/907b8c203efa475c41f4c8325f20812da9b92d34/runner/app/routes/image_to_video.py#L55) pipeline. This enhancement aids in better debugging and user experience. --- runner/app/routes/image_to_video.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runner/app/routes/image_to_video.py b/runner/app/routes/image_to_video.py index f61e6997..66544d52 100644 --- a/runner/app/routes/image_to_video.py +++ b/runner/app/routes/image_to_video.py @@ -59,6 +59,14 @@ async def image_to_video( ), ) + if height % 8 != 0 or width % 8 != 0: + return JSONResponse( + status_code=400, + content=http_error( + f"`height` and `width` have to be divisible by 8 but are {height} and {width}." + ), + ) + if seed is None: seed = random.randint(0, 2**32 - 1)