more refactor: interface to client; zoomConfig separate file
parent
1256af716b
commit
5f1f81a247
|
|
@ -0,0 +1,34 @@
|
|||
from dataclasses import dataclass
|
||||
from PIL import Image
|
||||
@dataclass
|
||||
class InfZoomConfig():
|
||||
common_prompt_pre:str
|
||||
prompts_array:list[str]
|
||||
common_prompt_suf:str
|
||||
negative_prompt:str
|
||||
num_outpainting_steps: int
|
||||
guidance_scale:float
|
||||
num_inference_steps:int
|
||||
custom_init_image:Image
|
||||
custom_exit_image:Image
|
||||
video_frame_rate:int
|
||||
video_zoom_mode:int
|
||||
video_start_frame_dupe_amount:int
|
||||
video_last_frame_dupe_amount:int
|
||||
inpainting_mask_blur:int
|
||||
inpainting_fill_mode:int
|
||||
zoom_speed:float
|
||||
seed:int
|
||||
outputsizeW:int
|
||||
outputsizeH:int
|
||||
batchcount:int
|
||||
sampler:str
|
||||
upscale_do:bool
|
||||
upscaler_name:str
|
||||
upscale_by:float
|
||||
overmask:int
|
||||
outpaintStrategy: str
|
||||
inpainting_denoising_strength:float=1
|
||||
inpainting_full_res:int =0
|
||||
inpainting_padding:int=0
|
||||
progress:any=None
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import math, time, os
|
||||
from dataclasses import dataclass
|
||||
import numpy as np
|
||||
from PIL import Image, ImageFilter, ImageOps, ImageDraw
|
||||
|
||||
|
|
@ -16,40 +15,8 @@ from .helpers import (
|
|||
from .sd_helpers import renderImg2Img, renderTxt2Img
|
||||
from .image import shrink_and_paste_on_blank
|
||||
from .video import ContinuousVideoWriter
|
||||
|
||||
@dataclass
|
||||
class InfZoomConfig():
|
||||
common_prompt_pre:str
|
||||
prompts_array:list[str]
|
||||
common_prompt_suf:str
|
||||
negative_prompt:str
|
||||
num_outpainting_steps: int
|
||||
guidance_scale:float
|
||||
num_inference_steps:int
|
||||
custom_init_image:Image
|
||||
custom_exit_image:Image
|
||||
video_frame_rate:int
|
||||
video_zoom_mode:int
|
||||
video_start_frame_dupe_amount:int
|
||||
video_last_frame_dupe_amount:int
|
||||
inpainting_mask_blur:int
|
||||
inpainting_fill_mode:int
|
||||
zoom_speed:float
|
||||
seed:int
|
||||
outputsizeW:int
|
||||
outputsizeH:int
|
||||
batchcount:int
|
||||
sampler:str
|
||||
upscale_do:bool
|
||||
upscaler_name:str
|
||||
upscale_by:float
|
||||
overmask:int
|
||||
outpaintStrategy: str
|
||||
inpainting_denoising_strength:float=1
|
||||
inpainting_full_res:int =0
|
||||
inpainting_padding:int=0
|
||||
progress:any=None
|
||||
|
||||
from .InfZoomConfig import InfZoomConfig
|
||||
|
||||
class InfZoomer:
|
||||
def __init__(self, config: InfZoomConfig) -> None:
|
||||
self.C = config
|
||||
|
|
@ -119,8 +86,8 @@ class InfZoomer:
|
|||
self.save2Collect(current_image, f"init_txt2img.png")
|
||||
self.current_seed = newseed
|
||||
|
||||
self.mask_width = math.trunc(self.width * 1/10 ) # was initially 512px => 128px
|
||||
self.mask_height = math.trunc(self.height * 1/10 ) # was initially 512px => 128px
|
||||
self.mask_width = self.width * 1//4 # was initially 512px => 128px
|
||||
self.mask_height = self.height * 1//4 # was initially 512px => 128px
|
||||
|
||||
self.num_interpol_frames = round(self.C.video_frame_rate * self.C.zoom_speed)
|
||||
|
||||
|
|
@ -143,8 +110,8 @@ class InfZoomer:
|
|||
|
||||
self.width = self.main_frames[0].width
|
||||
self.height = self.main_frames[0].height
|
||||
self.mask_width = math.trunc((self.width * 1/10) *(self.C.upscale_by))
|
||||
self.mask_height = math.trunc((self.height *1/10) * (self.C.upscale_by))
|
||||
self.mask_width = math.trunc((self.width * 1/4) *(self.C.upscale_by))
|
||||
self.mask_height = math.trunc((self.height *1/4) * (self.C.upscale_by))
|
||||
|
||||
if self.C.video_zoom_mode:
|
||||
self.main_frames = self.main_frames[::-1]
|
||||
|
|
@ -429,75 +396,3 @@ class InfZoomer:
|
|||
# resized_img = resized_img.filter(ImageFilter.SHARPEN)
|
||||
|
||||
return prev_step_img
|
||||
|
||||
|
||||
|
||||
# to be called from Gradio or other client
|
||||
def createZoom(
|
||||
common_prompt_pre:str,
|
||||
prompts_array:list[str],
|
||||
common_prompt_suf:str,
|
||||
negative_prompt:str,
|
||||
num_outpainting_steps: int,
|
||||
guidance_scale:float,
|
||||
num_inference_steps:int,
|
||||
custom_init_image:Image,
|
||||
custom_exit_image:Image,
|
||||
video_frame_rate:int,
|
||||
video_zoom_mode:int,
|
||||
video_start_frame_dupe_amount:int,
|
||||
video_last_frame_dupe_amount:int,
|
||||
inpainting_mask_blur:int,
|
||||
inpainting_fill_mode:int,
|
||||
zoom_speed:float,
|
||||
seed:int,
|
||||
outputsizeW:int,
|
||||
outputsizeH:int,
|
||||
batchcount:int,
|
||||
sampler:str,
|
||||
upscale_do:bool,
|
||||
upscaler_name:str,
|
||||
upscale_by:float,
|
||||
overmask:int,
|
||||
outpaintStrategy:str,
|
||||
inpainting_denoising_strength:float=1,
|
||||
inpainting_full_res:int =0,
|
||||
inpainting_padding:int=0,
|
||||
progress:any=None
|
||||
):
|
||||
izc = InfZoomConfig(
|
||||
common_prompt_pre,
|
||||
prompts_array,
|
||||
common_prompt_suf,
|
||||
negative_prompt,
|
||||
num_outpainting_steps,
|
||||
guidance_scale,
|
||||
num_inference_steps,
|
||||
custom_init_image,
|
||||
custom_exit_image,
|
||||
video_frame_rate,
|
||||
video_zoom_mode,
|
||||
video_start_frame_dupe_amount,
|
||||
video_last_frame_dupe_amount,
|
||||
inpainting_mask_blur,
|
||||
inpainting_fill_mode,
|
||||
zoom_speed,
|
||||
seed,
|
||||
outputsizeW,
|
||||
outputsizeH,
|
||||
batchcount,
|
||||
sampler,
|
||||
upscale_do,
|
||||
upscaler_name,
|
||||
upscale_by,
|
||||
overmask,
|
||||
outpaintStrategy,
|
||||
inpainting_denoising_strength,
|
||||
inpainting_full_res,
|
||||
inpainting_padding,
|
||||
progress
|
||||
)
|
||||
iz= InfZoomer(izc)
|
||||
r = iz.create_zoom()
|
||||
del iz
|
||||
return r
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
from .run import (InfZoomer)
|
||||
from .InfZoomConfig import InfZoomConfig
|
||||
from PIL import Image
|
||||
|
||||
# to be called from Gradio or other client
|
||||
def createZoom(
|
||||
common_prompt_pre:str,
|
||||
prompts_array:list[str],
|
||||
common_prompt_suf:str,
|
||||
negative_prompt:str,
|
||||
num_outpainting_steps: int,
|
||||
guidance_scale:float,
|
||||
num_inference_steps:int,
|
||||
custom_init_image:Image,
|
||||
custom_exit_image:Image,
|
||||
video_frame_rate:int,
|
||||
video_zoom_mode:int,
|
||||
video_start_frame_dupe_amount:int,
|
||||
video_last_frame_dupe_amount:int,
|
||||
inpainting_mask_blur:int,
|
||||
inpainting_fill_mode:int,
|
||||
zoom_speed:float,
|
||||
seed:int,
|
||||
outputsizeW:int,
|
||||
outputsizeH:int,
|
||||
batchcount:int,
|
||||
sampler:str,
|
||||
upscale_do:bool,
|
||||
upscaler_name:str,
|
||||
upscale_by:float,
|
||||
overmask:int,
|
||||
outpaintStrategy:str,
|
||||
inpainting_denoising_strength:float=1,
|
||||
inpainting_full_res:int =0,
|
||||
inpainting_padding:int=0,
|
||||
progress:any=None
|
||||
):
|
||||
izc = InfZoomConfig(
|
||||
common_prompt_pre,
|
||||
prompts_array,
|
||||
common_prompt_suf,
|
||||
negative_prompt,
|
||||
num_outpainting_steps,
|
||||
guidance_scale,
|
||||
num_inference_steps,
|
||||
custom_init_image,
|
||||
custom_exit_image,
|
||||
video_frame_rate,
|
||||
video_zoom_mode,
|
||||
video_start_frame_dupe_amount,
|
||||
video_last_frame_dupe_amount,
|
||||
inpainting_mask_blur,
|
||||
inpainting_fill_mode,
|
||||
zoom_speed,
|
||||
seed,
|
||||
outputsizeW,
|
||||
outputsizeH,
|
||||
batchcount,
|
||||
sampler,
|
||||
upscale_do,
|
||||
upscaler_name,
|
||||
upscale_by,
|
||||
overmask,
|
||||
outpaintStrategy,
|
||||
inpainting_denoising_strength,
|
||||
inpainting_full_res,
|
||||
inpainting_padding,
|
||||
progress
|
||||
)
|
||||
iz= InfZoomer(izc)
|
||||
r = iz.create_zoom()
|
||||
del iz
|
||||
return r
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import gradio as gr
|
||||
from .run import createZoom
|
||||
from .run_interface import createZoom
|
||||
import modules.shared as shared
|
||||
from webui import wrap_gradio_gpu_call
|
||||
from modules.ui import create_output_panel
|
||||
|
|
|
|||
Loading…
Reference in New Issue