diff options
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -84,6 +84,13 @@ class Handler(BaseHTTPRequestHandler): return if self.path == "/generate": + width = int(data.get("width", 1024)) + height = int(data.get("height", 1024)) + if width % 8 or height % 8: + # Match the one-shot CLI: reject bad dims up front with a clear + # client error instead of a downstream 500 or garbled output. + self._json(400, {"error": "width and height must be multiples of 8"}) + return try: image, elapsed = generate.generate( STATE["pipe"], @@ -92,8 +99,8 @@ class Handler(BaseHTTPRequestHandler): int(data.get("steps", 25)), float(data.get("guidance", 7.0)), data.get("seed"), - int(data.get("width", 1024)), - int(data.get("height", 1024)), + width, + height, ) except torch.OutOfMemoryError: torch.xpu.empty_cache() |
