1
0
Fork 0

complete SD panorama tiles

This commit is contained in:
Sean Sube 2023-12-02 20:40:36 -06:00
parent 4b491ec4d5
commit d4611e958c
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 8 additions and 4 deletions

View File

@ -13,7 +13,8 @@
# limitations under the License. # limitations under the License.
import inspect import inspect
from typing import Callable, List, Optional, Union from math import ceil
from typing import Callable, List, Optional, Tuple, Union
import numpy as np import numpy as np
import PIL import PIL
@ -356,13 +357,16 @@ class OnnxStableDiffusionPanoramaPipeline(DiffusionPipeline):
f" {negative_prompt_embeds.shape}." f" {negative_prompt_embeds.shape}."
) )
def get_views(self, panorama_height, panorama_width, window_size, stride): def get_views(
self, panorama_height: int, panorama_width: int, window_size: int, stride: int
) -> Tuple[List[Tuple[int, int, int, int]], Tuple[int, int]]:
# Here, we define the mappings F_i (see Eq. 7 in the MultiDiffusion paper https://arxiv.org/abs/2302.08113) # Here, we define the mappings F_i (see Eq. 7 in the MultiDiffusion paper https://arxiv.org/abs/2302.08113)
panorama_height /= 8 panorama_height /= 8
panorama_width /= 8 panorama_width /= 8
num_blocks_height = abs((panorama_height - window_size) // stride) + 1 num_blocks_height = ceil(abs((panorama_height - window_size) / stride)) + 1
num_blocks_width = abs((panorama_width - window_size) // stride) + 1 num_blocks_width = ceil(abs((panorama_width - window_size) / stride)) + 1
total_num_blocks = int(num_blocks_height * num_blocks_width) total_num_blocks = int(num_blocks_height * num_blocks_width)
logger.debug( logger.debug(
"panorama generated %s views, %s by %s blocks", "panorama generated %s views, %s by %s blocks",