From 065df239029e06b7fc996c698c25867860b545fa Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Fri, 12 Jan 2024 23:41:16 -0600 Subject: [PATCH] more lint --- api/onnx_web/chain/tile.py | 14 +++++++++----- api/onnx_web/server/api.py | 9 ++++++--- gui/src/types/api-v2.ts | 9 ++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/api/onnx_web/chain/tile.py b/api/onnx_web/chain/tile.py index 6b9b9b70..2b6e6ab8 100644 --- a/api/onnx_web/chain/tile.py +++ b/api/onnx_web/chain/tile.py @@ -26,7 +26,11 @@ class TileCallback(Protocol): """ def __call__( - self, sources: List[Image.Image], mask: Image.Image, dims: Tuple[int, int, int], progress: Tuple[int, int] + self, + sources: List[Image.Image], + mask: Image.Image, + dims: Tuple[int, int, int], + progress: Tuple[int, int], ) -> StageResult: """ Run this stage against a single tile. @@ -273,9 +277,7 @@ def process_tile_stack( single_tile = total_tiles == 1 for counter, (left, top) in enumerate(tile_coords): - logger.info( - "processing tile %s of %s, %sx%s", counter, total_tiles, left, top - ) + logger.info("processing tile %s of %s, %sx%s", counter, total_tiles, left, top) right = left + tile bottom = top + tile @@ -343,7 +345,9 @@ def process_tile_stack( tile_mask = mask.crop((left, top, right, bottom)) for image_filter in filters: - tile_stack = image_filter(tile_stack, tile_mask, (left, top, tile), (counter, total_tiles)) + tile_stack = image_filter( + tile_stack, tile_mask, (left, top, tile), (counter, total_tiles) + ) # TODO: this should be inverted to extract them from the result if isinstance(tile_stack, list): diff --git a/api/onnx_web/server/api.py b/api/onnx_web/server/api.py index 440203f3..100ce0cb 100644 --- a/api/onnx_web/server/api.py +++ b/api/onnx_web/server/api.py @@ -160,7 +160,7 @@ def image_reply( return data -def multi_image_reply(results: Dict[str, Any]): +def multi_image_reply(results: List[Dict[str, Any]]): return jsonify( { "results": results, @@ -180,7 +180,10 @@ def introspect(server: ServerContext, app: Flask): return { "name": "onnx-web", "routes": [ - {"path": url_from_rule(rule), "methods": list(rule.methods or []).sort()} + { + "path": url_from_rule(rule), + "methods": list(rule.methods or []), + } for rule in app.url_map.iter_rules() ], } @@ -687,7 +690,7 @@ def job_status(server: ServerContext, pool: DevicePoolExecutor): outputs = None metadata = None if progress.result is not None and len(progress.result) > 0: - # TODO: the names should be attached to the result somehow rather than recomputing them + # TODO: the names should be attached to the result when it is saved rather than recomputing them outputs = make_output_names(server, job_name, len(progress.result)) metadata = progress.result.metadata diff --git a/gui/src/types/api-v2.ts b/gui/src/types/api-v2.ts index 4e992ba7..2545877b 100644 --- a/gui/src/types/api-v2.ts +++ b/gui/src/types/api-v2.ts @@ -1,6 +1,13 @@ import { RetryParams } from './api.js'; import { BaseImgParams, HighresParams, Img2ImgParams, InpaintParams, Txt2ImgParams, UpscaleParams } from './params.js'; +export interface Border { + left: number; + right: number; + top: number; + bottom: number; +} + export interface Progress { current: number; total: number; @@ -26,7 +33,7 @@ export interface ImageMetadata; models: Array; - border: unknown; // TODO: type + border: Border; highres: HighresParams; upscale: UpscaleParams; size: Size;