mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into feat/db/migrations
This commit is contained in:
commit
cc18d86f29
@ -5,7 +5,6 @@ from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
|
||||
from fastapi import Body
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic.networks import AnyHttpUrl
|
||||
from typing_extensions import Annotated
|
||||
@ -112,17 +111,7 @@ class URLModelSource(StringLikeSource):
|
||||
return str(self.url)
|
||||
|
||||
|
||||
# Body() is being applied here rather than Field() because otherwise FastAPI will
|
||||
# refuse to generate a schema. Relevant links:
|
||||
#
|
||||
# "Model Manager Refactor Phase 1 - SQL-based config storage
|
||||
# https://github.com/invoke-ai/InvokeAI/pull/5039#discussion_r1389752119 (comment)
|
||||
# Param: xyz can only be a request body, using Body() when using discriminated unions
|
||||
# https://github.com/tiangolo/fastapi/discussions/9761
|
||||
# Body parameter cannot be a pydantic union anymore sinve v0.95
|
||||
# https://github.com/tiangolo/fastapi/discussions/9287
|
||||
|
||||
ModelSource = Annotated[Union[LocalModelSource, HFModelSource, URLModelSource], Body(discriminator="type")]
|
||||
ModelSource = Annotated[Union[LocalModelSource, HFModelSource, URLModelSource], Field(discriminator="type")]
|
||||
|
||||
|
||||
class ModelInstallJob(BaseModel):
|
||||
|
@ -191,11 +191,15 @@ def calc_tiles_min_overlap(
|
||||
assert min_overlap < tile_height
|
||||
assert min_overlap < tile_width
|
||||
|
||||
# The If Else catches the case when the tile size is larger than the images size and just clips the number of tiles to 1
|
||||
num_tiles_x = math.ceil((image_width - min_overlap) / (tile_width - min_overlap)) if tile_width < image_width else 1
|
||||
num_tiles_y = (
|
||||
math.ceil((image_height - min_overlap) / (tile_height - min_overlap)) if tile_height < image_height else 1
|
||||
)
|
||||
# catches the cases when the tile size is larger than the images size and adjusts the tile size
|
||||
if image_width < tile_width:
|
||||
tile_width = image_width
|
||||
|
||||
if image_height < tile_height:
|
||||
tile_height = image_height
|
||||
|
||||
num_tiles_x = math.ceil((image_width - min_overlap) / (tile_width - min_overlap))
|
||||
num_tiles_y = math.ceil((image_height - min_overlap) / (tile_height - min_overlap))
|
||||
|
||||
# tiles[y * num_tiles_x + x] is the tile for the y'th row, x'th column.
|
||||
tiles: list[Tile] = []
|
||||
|
@ -47,7 +47,7 @@ dependencies = [
|
||||
"easing-functions",
|
||||
"einops",
|
||||
"facexlib",
|
||||
"fastapi~=0.104.1",
|
||||
"fastapi~=0.105.0",
|
||||
"fastapi-events~=0.9.1",
|
||||
"huggingface-hub~=0.16.4",
|
||||
"imohash",
|
||||
|
@ -241,6 +241,28 @@ def test_calc_tiles_min_overlap_not_evenly_divisible():
|
||||
assert tiles == expected_tiles
|
||||
|
||||
|
||||
def test_calc_tiles_min_overlap_tile_bigger_than_image():
|
||||
"""Test calc_tiles_min_overlap() behavior when the tile is nigger than the image"""
|
||||
# Parameters mimic roughly the same output as the original tile generations of the same test name
|
||||
tiles = calc_tiles_min_overlap(
|
||||
image_height=1024,
|
||||
image_width=1024,
|
||||
tile_height=1408,
|
||||
tile_width=1408,
|
||||
min_overlap=128,
|
||||
)
|
||||
|
||||
expected_tiles = [
|
||||
# single tile
|
||||
Tile(
|
||||
coords=TBLR(top=0, bottom=1024, left=0, right=1024),
|
||||
overlap=TBLR(top=0, bottom=0, left=0, right=0),
|
||||
),
|
||||
]
|
||||
|
||||
assert tiles == expected_tiles
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
[
|
||||
"image_height",
|
||||
|
Loading…
Reference in New Issue
Block a user