Tiles / app.py
XINZHANG94's picture
regional slpirt
a911c0d
import gradio as gr
import os
from PIL import Image, ImageFont, ImageDraw
from typing import List
from setting_names import names_mapping
from utils import (
TilePaint,
PixelColorPalette,
TileCurvedHexagonPaint,
TileHexagonPaint,
ColorSelection,
ImageBoarder,
ImageText,
image_paste_methods,
HexagonGrid,
ColorPalette,
ImageManipulation,
RegionalSplit
)
langangue = 'cn'
abs_path_font = os.path.abspath(__file__).split(os.sep)[:-1]
font_abs_path = os.sep.join(abs_path_font)
names = dict((label_name, lan[langangue]) for label_name, lan in names_mapping.items())
def get_image_examples():
examples=[
os.path.join(os.path.dirname(__file__), "images/dam_01.png"),
os.path.join(os.path.dirname(__file__), "images/dam_02.png"),
os.path.join(os.path.dirname(__file__), "images/dam_03.png"),
os.path.join(os.path.dirname(__file__), "images/dam_04.png"),
os.path.join(os.path.dirname(__file__), "images/dam_05.png"),
os.path.join(os.path.dirname(__file__), "images/dam_06.png"),
]
return examples
# step1 reduce image colors
def pixel_palette_image(raw_image: Image.Image,
transformation_method: str,
rgb_palette: str,
max_colors: int,
distance_strategy: str,) -> List[Image.Image]:
"""This function will reduce the color into wanted number of colors."""
if not rgb_palette:
rgb_palette = None
print("mapping to colors...")
pcp = PixelColorPalette(pil_image=raw_image,
transformation_method=transformation_method,
rgb_palette=rgb_palette,
max_colors=max_colors,
distance_strategy=distance_strategy
)
image = pcp.translate()
cp = ColorPalette(
pil_image=image,
color_block_size=1,
)
rgb_string = cp.rgbs_string
print("Mapped to limited colors...")
return [image, rgb_string]
def map_tiles(
image: Image.Image,
painting_width: int,
painting_height: int,
tile_preset: str,
tile_type: str,
tile_scaler: float,
curvature: float,
tip_type: str,
gap_horizontal: int,
gap_vertical: int,
gap_color: str,
tile_edge_width: int,
tile_edge_color: str,
color_aggregate_type: str,
x_count: int,
y_count: int,
width_extend: int,
height_extend: int,
region_width: int,
font_name: str,
font_size: str,
text_color: str,
) -> None:
print("Creating Tiles...")
if tile_preset.startswith("large"):
tile_scaler = 1
curvature = 0.03
elif tile_preset.startswith("small"):
tile_scaler = 0.5
curvature = 0.05
if tile_type == "Hexagon":
paint_tile = TileHexagonPaint
parameters = {
'width': painting_width,
'height': painting_height,
'ratio_edge': tile_scaler,
'gap_horizontal': gap_horizontal,
'gap_vertical': gap_vertical,
'gap_color': gap_color,
'tile_edge_width': tile_edge_width,
'tile_edge_color': tile_edge_color
}
elif tile_type == "HexagonCurved":
paint_tile = TileCurvedHexagonPaint
parameters = {
'width': painting_width,
'height': painting_height,
'ratio_edge': tile_scaler,
'curvature': curvature,
'tip_type': tip_type,
'gap_horizontal': gap_horizontal,
'gap_vertical': gap_vertical,
'gap_color': gap_color,
'tile_edge_width': tile_edge_width,
'tile_edge_color': tile_edge_color
}
tiles = paint_tile(**parameters)
cs = ColorSelection(image, color_aggregate_type, tiles)
pil_image = cs.translate_image_tensor_v2()
print("Created tileed image...")
rs = RegionalSplit(x_count, y_count, tile_paint=tiles)
width = tiles.width
height = tiles.height
larger_image = Image.new('RGB', (width + width_extend * 2, height + height_extend * 2), (255, 255, 255))
larger_image.paste(pil_image, (width_extend, height_extend))
try:
font = ImageFont.truetype(font_name, font_size)
except IOError:
print(f"Font '{font_name}' not found. Using default font.")
font = ImageFont.load_default()
draw = ImageDraw.Draw(larger_image)
for (x_center, y_center), name in zip(rs.region_x_y_centers, rs.region_names):
b_points = rs.get_border(x_center, y_center)
b_points = [(x + width_extend, y + height_extend) for x, y in b_points]
x_mid, y_mid = rs.get_mid(x_center, y_center)
draw.line(b_points + [b_points[0]], fill=text_color, width=region_width)
draw.text((x_center + width_extend, (y_center + y_mid)/2 + height_extend), name, fill=text_color, font=font)
return larger_image
# step 2.1 regional split
def reginal_split(image_pil: Image.Image,
x_count: int,
y_count: int,
width_extend: int,
height_extend: int,
region_width: int,
font_name: str,
font_size: str,
text_color: str,
PaintTilesHexagon: TilePaint):
rs = RegionalSplit(x_count, y_count, tile_paint=PaintTilesHexagon)
width = PaintTilesHexagon.width
height = PaintTilesHexagon.height
larger_image = Image.new('RGB', (width + width_extend * 2, height + height_extend * 2), (255, 255, 255))
larger_image.paste(image_pil, (width_extend, height_extend))
try:
font = ImageFont.truetype(font_name, font_size)
except IOError:
print(f"Font '{font_name}' not found. Using default font.")
font = ImageFont.load_default()
draw = ImageDraw.Draw(larger_image)
for (x_center, y_center), name in zip(rs.region_x_y_centers, rs.region_names):
b_points = rs.get_border(x_center, y_center)
b_points = [(x + width_extend, y + height_extend) for x, y in b_points]
x_mid, y_mid = rs.get_mid(x_center, y_center)
draw.line(b_points + [b_points[0]], fill=text_color, width=region_width)
draw.text((x_center + width_extend, (y_center + y_mid)/2 + height_extend), name, fill=text_color, font=font)
return larger_image
# step3 apply boarder
def apply_boarder(image: Image.Image,
left_boarder_dist: int,
right_boarder_dist: int,
top_boarder_dist: int,
bottom_boarder_dist: int,
line_width: int,
line_color: str,
margin_left: int,
margin_right: int,
margin_top: int,
margin_bottom: int) -> Image.Image:
print("Drawing boarder...")
ib = ImageBoarder(
image=image,
line_distances={"left": left_boarder_dist, "right": right_boarder_dist, "top": top_boarder_dist, "bottom": bottom_boarder_dist},
line_width=line_width,
line_color=line_color,
margin_widths={"left": margin_left, "right": margin_right, "top": margin_top, "bottom": margin_bottom}
)
image = ib.add_custom_lines()
return image
# step4 create header text
def create_header_text(
image: Image.Image,
width: int,
height: int,
bg_color: str,
font_name: str,
font_size: int,
text_color: str,
x_pos: int,
y_pos: int,
text: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing header text...")
ti = ImageText(
width=width,
height=height,
background_color=bg_color,
text=text,
font_name=font_name,
font_size=font_size,
text_color=text_color,
text_position=(x_pos, y_pos),
abs_path=font_abs_path
)
text_image = ti.create_text_image()
image_paste = image_paste_methods(text_image, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
# step5 color grid
def create_color_grid(
image: Image.Image,
color_list: str,
hex_width: int,
hex_height: int,
tip_height: int,
bg_color: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing color grid...")
hg = HexagonGrid(
colors=color_list,
width=hex_width,
hex_height=hex_height,
tip_height=tip_height,
bg_color=bg_color
)
grid = hg.create_color_hexagon_grid()
image_paste = image_paste_methods(grid, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
# step6 top edge label
def top_edge_label(
image: Image.Image,
width: int,
height: int,
bg_color: str,
font_name: str,
font_size: int,
text_color: str,
x_pos: int,
y_pos: int,
text: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing top label...")
ti = ImageText(
width=width,
height=height,
background_color=bg_color,
text=text,
font_name=font_name,
font_size=font_size,
text_color=text_color,
text_position=(x_pos, y_pos),
abs_path=font_abs_path
)
text_image = ti.create_text_image()
image_paste = image_paste_methods(text_image, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
# step7 left edge label
def left_edge_label(
image: Image.Image,
width: int,
height: int,
bg_color: str,
font_name: str,
font_size: int,
text_color: str,
x_pos: int,
y_pos: int,
text: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing left label...")
ti = ImageText(
width=width,
height=height,
background_color=bg_color,
text=text,
font_name=font_name,
font_size=font_size,
text_color=text_color,
text_position=(x_pos, y_pos),
abs_path=font_abs_path
)
text_image = ti.create_text_image()
im = ImageManipulation(text_image)
text_image = im.rotation(90)
image_paste = image_paste_methods(text_image, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
# step8 right edge label
def right_edge_label(
image: Image.Image,
width: int,
height: int,
bg_color: str,
font_name: str,
font_size: int,
text_color: str,
x_pos: int,
y_pos: int,
text: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing right label...")
ti = ImageText(
width=width,
height=height,
background_color=bg_color,
text=text,
font_name=font_name,
font_size=font_size,
text_color=text_color,
text_position=(x_pos, y_pos),
abs_path=font_abs_path
)
text_image = ti.create_text_image()
im = ImageManipulation(text_image)
text_image = im.rotation(90)
image_paste = image_paste_methods(text_image, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
# step8 bot edge label
def bot_edge_label(
image: Image.Image,
width: int,
height: int,
bg_color: str,
font_name: str,
font_size: int,
text_color: str,
x_pos: int,
y_pos: int,
text: str,
onto_position_x: int,
onto_position_y: int
) -> Image.Image:
print("Drawing bottom label...")
ti = ImageText(
width=width,
height=height,
background_color=bg_color,
text=text,
font_name=font_name,
font_size=font_size,
text_color=text_color,
text_position=(x_pos, y_pos),
abs_path=font_abs_path
)
text_image = ti.create_text_image()
image_paste = image_paste_methods(text_image, image, "no-resize", onto_position_x, onto_position_y, None, None)
result_image, result_mask = image_paste.paste_onto()
return result_image
with gr.Blocks() as demo:
gr.Markdown(names["page_header"])
with gr.Row(equal_height=False):
with gr.Column():
with gr.Accordion(open=True, label=names['raw_image']):
raw_image = gr.Image(type="pil")
btn = gr.Button(names['run'], variant="primary")
# parameters for image color reduce
with gr.Accordion(open=True, label=names["image_color_reduce_settings"]):
transformation_method = gr.Dropdown(
["original",
"lab_color",
"lab_lightness",
"lab_red_green",
"lab_blue_yellow",
"brightness",
"hsv_color",
"hue",
"saturation",
"value"], label=names["transformation_method"], value="original")
max_colors = gr.Slider(minimum=1, maximum=30, step=1, value=16, label=names["max_colors"])
distance_strategy = gr.Dropdown(["euclidean", "cosine"], label=names["distance_strategy"], value="euclidean")
rgb_palette = gr.Textbox(placeholder=names["rgb_palette_place_holder"], label=names["rgb_palette"])
color_list = gr.Textbox(label=names["color_list"])
# parameters for tile settings
with gr.Accordion(open=False, label=names["tile_settings"]):
painting_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['painting_width'], value=4800)
painting_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['painting_height'], value=7000)
tile_preset = gr.Dropdown(["large(50*120)", "small(25*60)", "customize"], label=names["tile_preset"], value="large(50*120)")
tile_type = gr.Dropdown(["Hexagon", "HexagonCurved"], label=names["tile_type"], value="HexagonCurved")
tile_scaler = gr.Number(precision=None, minimum=0.1, maximum=10, step=0.01, label=names['tile_scaler'], value=1.0)
curvature = gr.Number(precision=None, minimum=0.01, maximum=10, step=0.01, label=names['curvature'], value=0.03)
tip_type = gr.Dropdown(['line', 'curve'], label=names["tip_type"], value='curve')
gap_horizontal = gr.Number(precision=0, minimum=0, maximum=0, step=1, label=names['gap_horizontal'], value=0)
gap_vertical = gr.Number(precision=0, minimum=0, maximum=0, step=1, label=names['gap_vertical'], value=0)
gap_color = gr.Dropdown(['black', 'white'], label=names["gap_color"], value='black')
tile_edge_width = gr.Number(precision=0, minimum=0, maximum=20, step=1, label=names['tile_edge_width'], value=1)
tile_edge_color = gr.Dropdown(['red'], label=names["tile_edge_color"], value='red')
color_aggregate_type = gr.Dropdown(['average', 'marjority'], label=names["color_aggregate_type"], value='marjority')
x_count = gr.Number(precision=0, minimum=1, maximum=10, step=1, label=names['x_count'], value=5)
y_count = gr.Number(precision=0, minimum=2, maximum=20, step=2, label=names['y_count'], value=4)
width_extend = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['width_extend'], value=300)
height_extend = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['height_extend'], value=300)
region_width = gr.Number(precision=0, minimum=1, maximum=10, step=1, label=names['region_width'], value=5)
region_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["region_font_name"], value='εŽζ–‡η»†ι»‘.ttf')
region_font_size = gr.Number(precision=0, minimum=1, maximum=100, step=1, label=names['region_font_size'], value=60)
region_text_color = gr.Dropdown(['red'], label=names["region_text_color"], value='red')
# parameters for boarder settings
with gr.Accordion(open=False, label=names["boader_settings"]):
left_boarder_dist = gr.Number(precision=0, minimum=-999, maximum=999, step=1, label=names['left_boarder_dist'], value=-300)
right_boarder_dist = gr.Number(precision=0, minimum=-999, maximum=999, step=1, label=names['right_boarder_dist'], value=-300)
top_boarder_dist = gr.Number(precision=0, minimum=-999, maximum=999, step=1, label=names['top_boarder_dist'], value=-300)
bottom_boarder_dist = gr.Number(precision=0, minimum=-999, maximum=999, step=1, label=names['bottom_boarder_dist'], value=-300)
line_width = gr.Number(precision=0, minimum=1, maximum=99, step=1, label=names['line_width'], value=10)
line_color = gr.Dropdown(['red', 'blue'], label=names["line_color"], value='red')
margin_left = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['margin_left'], value=350)
margin_right = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['margin_right'], value=350)
margin_top = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['margin_top'], value=700)
margin_bottom = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['margin_bottom'], value=200)
# parameters for header text settings
with gr.Accordion(open=False, label=names["header_text_settings"]):
header_text_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_width'], value=3000)
header_text_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_height'], value=400)
header_text_bg_color = gr.Dropdown(['black', 'white'], label=names["text_bg_color"], value='white')
header_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["font_name"], value='εŽζ–‡η»†ι»‘.ttf')
header_font_size = gr.Slider(minimum=1, maximum=999, step=1, value=80, label=names["font_size"])
header_text_color = gr.Dropdown(['black', 'white'], label=names["text_color"], value='black')
header_text_x_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_x_pos'], value=300)
header_text_y_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_y_pos'], value=0)
header_text_value = (
"户尺寸: W4800*H7000MM (δΊ§ε“ε°Ίε―ΈοΌšW4800*H7066MM)\n"
"格:33*80MMε•ι’—η²’ε―†ζ‹ΌεΈ¦θΎΉε°ι³žε…‰\n"
"ε·₯θ‰ΊοΌšζ‰‹ε·₯注框\n"
"ε€‡ζ³¨οΌšι’œθ‰²ε‚θ€ƒοΌˆ16δΈͺ色)"
)
header_text = gr.Text(value=header_text_value, label=names["text"])
header_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=300)
header_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=150)
# parameters for grid settings
with gr.Accordion(open=False, label=names["grid_settings"]):
hex_width = gr.Number(precision=0, minimum=1, maximum=999, step=1, label=names['hex_width'], value=150)
hex_height = gr.Number(precision=0, minimum=1, maximum=999, step=1, label=names['hex_height'], value=180)
tip_height = gr.Number(precision=0, minimum=1, maximum=999, step=1, label=names['tip_height'], value=80)
grid_bg_color = gr.Dropdown(['black', 'white'], label=names["grid_bg_color"], value='white')
grid_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=2300)
grid_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=400)
# parameters for top edge text settings
with gr.Accordion(open=False, label=names["top_edge_text_setting"]):
top_text_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_width'], value=500)
top_text_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_height'], value=120)
top_text_bg_color = gr.Dropdown(['black', 'white'], label=names["text_bg_color"], value='white')
top_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["font_name"], value='εŽζ–‡η»†ι»‘.ttf')
top_font_size = gr.Slider(minimum=1, maximum=999, step=1, value=100, label=names["font_size"])
top_text_color = gr.Dropdown(['black', 'white'], label=names["text_color"], value='black')
top_text_x_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_x_pos'], value=0)
top_text_y_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_y_pos'], value=0)
top_text_value = (
"4800mm"
)
top_text = gr.Text(value=top_text_value, label=names["text"])
top_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=2800)
top_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=800)
# parameters for left edge text settings
with gr.Accordion(open=False, label=names["left_edge_text_setting"]):
left_text_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_width'], value=300)
left_text_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_height'], value=80)
left_text_bg_color = gr.Dropdown(['black', 'white'], label=names["text_bg_color"], value='white')
left_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["font_name"], value='εŽζ–‡η»†ι»‘.ttf')
left_font_size = gr.Slider(minimum=1, maximum=999, step=1, value=60, label=names["font_size"])
left_text_color = gr.Dropdown(['black', 'white'], label=names["text_color"], value='black')
left_text_x_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_x_pos'], value=0)
left_text_y_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_y_pos'], value=0)
left_text_value = (
"7066mm"
)
left_text = gr.Text(value=left_text_value, label=names["text"])
left_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=550)
left_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=3800)
# parameters for right edge text settings
with gr.Accordion(open=False, label=names["right_edge_text_setting"]):
right_text_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_width'], value=300)
right_text_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_height'], value=80)
right_text_bg_color = gr.Dropdown(['black', 'white'], label=names["text_bg_color"], value='white')
right_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["font_name"], value='εŽζ–‡η»†ι»‘.ttf')
right_font_size = gr.Slider(minimum=1, maximum=999, step=1, value=60, label=names["font_size"])
right_text_color = gr.Dropdown(['black', 'white'], label=names["text_color"], value='black')
right_text_x_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_x_pos'], value=0)
right_text_y_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_y_pos'], value=0)
right_text_value = (
"7000mm"
)
right_text = gr.Text(value=right_text_value, label=names["text"])
right_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=5450)
right_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=3800)
# parameters for bot edge text settings
with gr.Accordion(open=False, label=names["bot_edge_text_setting"]):
bot_text_width = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_width'], value=300)
bot_text_height = gr.Number(precision=0, minimum=1, maximum=9999, step=1, label=names['text_height'], value=80)
bot_text_bg_color = gr.Dropdown(['black', 'white'], label=names["text_bg_color"], value='white')
bot_font_name = gr.Dropdown(['εŽζ–‡η»†ι»‘.ttf'], label=names["font_name"], value='εŽζ–‡η»†ι»‘.ttf')
bot_font_size = gr.Slider(minimum=1, maximum=999, step=1, value=60, label=names["font_size"])
bot_text_color = gr.Dropdown(['black', 'white'], label=names["text_color"], value='black')
bot_text_x_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_x_pos'], value=0)
bot_text_y_pos = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['text_y_pos'], value=0)
bot_text_value = (
"4800mm"
)
bot_text = gr.Text(value=bot_text_value, label=names["text"])
bot_onto_position_x = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_x'], value=2800)
bot_onto_position_y = gr.Number(precision=0, minimum=0, maximum=9999, step=1, label=names['onto_position_y'], value=8000)
with gr.Column():
final_image = gr.Image(type="pil", label=names['output_image'])
gr.Examples(
examples=get_image_examples(),
inputs=[raw_image],
fn=None,
outputs=[final_image],
cache_examples=False,
label=names['examples']
)
btn.click(
fn=pixel_palette_image,
inputs=[
raw_image,
transformation_method,
rgb_palette,
max_colors,
distance_strategy
],
outputs=[final_image, color_list]
).then(
fn=map_tiles,
inputs=[
final_image,
painting_width,
painting_height,
tile_preset,
tile_type,
tile_scaler,
curvature,
tip_type,
gap_horizontal,
gap_vertical,
gap_color,
tile_edge_width,
tile_edge_color,
color_aggregate_type,
x_count,
y_count,
width_extend,
height_extend,
region_width,
region_font_name,
region_font_size,
region_text_color
],
outputs=final_image
).then(
fn=apply_boarder,
inputs=[
final_image,
left_boarder_dist,
right_boarder_dist,
top_boarder_dist,
bottom_boarder_dist,
line_width,
line_color,
margin_left,
margin_right,
margin_top,
margin_bottom
],
outputs=final_image
).then(
fn=create_header_text,
inputs=[
final_image,
header_text_width,
header_text_height,
header_text_bg_color,
header_font_name,
header_font_size,
header_text_color,
header_text_x_pos,
header_text_y_pos,
header_text,
header_onto_position_x,
header_onto_position_y
],
outputs=final_image
).then(
fn=create_color_grid,
inputs=[
final_image,
color_list,
hex_width,
hex_height,
tip_height,
grid_bg_color,
grid_onto_position_x,
grid_onto_position_y
],
outputs=final_image
).then(
fn=top_edge_label,
inputs=[
final_image,
top_text_width,
top_text_height,
top_text_bg_color,
top_font_name,
top_font_size,
top_text_color,
top_text_x_pos,
top_text_y_pos,
top_text,
top_onto_position_x,
top_onto_position_y
],
outputs=final_image
).then(
fn=left_edge_label,
inputs=[
final_image,
left_text_width,
left_text_height,
left_text_bg_color,
left_font_name,
left_font_size,
left_text_color,
left_text_x_pos,
left_text_y_pos,
left_text,
left_onto_position_x,
left_onto_position_y
],
outputs=final_image
).then(
fn=left_edge_label,
inputs=[
final_image,
right_text_width,
right_text_height,
right_text_bg_color,
right_font_name,
right_font_size,
right_text_color,
right_text_x_pos,
right_text_y_pos,
right_text,
right_onto_position_x,
right_onto_position_y
],
outputs=final_image
).then(
fn=bot_edge_label,
inputs=[
final_image,
bot_text_width,
bot_text_height,
bot_text_bg_color,
bot_font_name,
bot_font_size,
bot_text_color,
bot_text_x_pos,
bot_text_y_pos,
bot_text,
bot_onto_position_x,
bot_onto_position_y
],
outputs=final_image
)
demo.launch(share=False)