Skip to content

Commit

Permalink
Sephira pantie converter Ver.1.0, fixed Eyo
Browse files Browse the repository at this point in the history
  • Loading branch information
TenteEEEE committed Jul 24, 2021
1 parent a51ffa1 commit eac4def
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 2 deletions.
Binary file added body/body_sephira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mask/bra_sephira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mask/bra_sephira_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mask/mask_sephira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/bra_sephira_shade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/sephira_bra_ext1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/sephira_bra_ext2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/sephira_pantie_ext.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/sephira_ribbon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added material/sephira_ribbon_shade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
|![test](./sample/wolferia_pantie.png)|![test](./sample/inakokoa_pantie.png)|
|[先呼巣~ホーニーサキュバス](https://booth.pm/ja/items/2294683)|[イヨ](https://booth.pm/ja/items/2630437)|
|![test](./sample/succubus_pantie.png)|![test](./sample/eyo_pantie.png)|
|[セフィラ](https://booth.pm/ja/items/2953001)||
|![test](./sample/sephira_pantie.png)||

## スペシャルサンクス
[Booth:キッシュちゃん](https://mutachannel.booth.pm/items/954376)
Expand Down Expand Up @@ -220,6 +222,8 @@ When you want to know the help, please run `python patch.py -h`
|![test](./sample/wolferia_pantie.png)|![test](./sample/inakokoa_pantie.png)|
|[Succubus](https://booth.pm/ja/items/2294683)|[Eyo](https://booth.pm/ja/items/2630437)|
|![test](./sample/succubus_pantie.png)|![test](./sample/eyo_pantie.png)|
|[Sephira](https://booth.pm/ja/items/2953001)||
|![test](./sample/sephira_pantie.png)||

## Special thanks
[Quiche model](https://mutachannel.booth.pm/items/954376)
Expand Down
Binary file added sample/sephira_pantie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/models/eyo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class patcher(patcher):
def __init__(self, body='./body/body_eyo.png', **options):
super().__init__('イヨ', body=body, pantie_position=[1423, 877], **options)
self.mask = io.imread('./mask/mask_eyo.png')
self.bra_position = [298, 1301]
try:
self.use_ribbon_mesh = self.options['use_ribbon_mesh']
except:
Expand Down Expand Up @@ -77,7 +76,7 @@ def gen_bra(self, image):
front_color, front_shade_color = self.extract_bra_color(pantie)
center = pantie[20:170, -200:-15, :3][:, ::-1]
center = resize(center, [3.7, 3.7])
bra_center = np.float32(io.imread('./mask/bra_eyo_center.png') / 255)
bra_center = np.copy(self.bra_center)
bra_center[:center.shape[0], 55:55 + center.shape[1], :3] = center * np.float32(bra_center[:center.shape[0], 55:55 + center.shape[1], :3] > 0)
bra = self.bra[:, :, :3] * front_color
bra_shade = (self.bra_shade[:, :, -1])[:, :, None] * front_shade_color
Expand Down
135 changes: 135 additions & 0 deletions src/models/sephira.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from PIL import Image, ImageOps
import numpy as np
import skimage.io as io
from src.models.class_patcher import patcher
from src.utils.imgproc import *
from skimage.color import rgb2hsv, hsv2rgb


class patcher(patcher):
def __init__(self, body='./body/body_sephira.png', **options):
super().__init__('セフィラ', body=body, pantie_position=[737, 2421], **options)
self.mask = io.imread('./mask/mask_sephira.png')
try:
self.use_ribbon_mesh = self.options['use_ribbon_mesh']
except:
self.use_ribbon_mesh = self.ask(question='Use ribbon mesh?', default=True)

self.bra_position = [136, 1583]
self.bra = np.float32(io.imread('./mask/bra_sephira.png') / 255)
self.bra_center = np.float32(io.imread('./mask/bra_sephira_center.png') / 255)
self.bra_shade = np.float32(io.imread('./material/bra_sephira_shade.png') / 255)
self.bra_shade_alpha = self.bra_shade[:, :, -1]

self.pantie_extra_position = [1624, 3255]
self.pantie_extra_shade = np.float32(io.imread('./material/sephira_pantie_ext.png') / 255)

self.bra_extra_position1 = [10, 1786]
self.bra_extra_position2 = [10, 2958]
self.bra_extra_shade1 = np.float32(io.imread('./material/sephira_bra_ext1.png') / 255)
self.bra_extra_shade2 = np.float32(io.imread('./material/sephira_bra_ext2.png') / 255)

if self.use_ribbon_mesh:
self.ribbon_position = [1585, 2602]
self.ribbon_shade = np.float32(io.imread('./material/sephira_ribbon_shade.png') / 255)[:, :, -1]
self.ribbon = np.float32(io.imread('./material/sephira_ribbon.png') / 255)

def convert(self, image):
pantie = np.array(image)
if self.use_ribbon_mesh:
pantie = ribbon_inpaint(pantie)

patch = np.copy(pantie[-140:-5, 546:, :])
[pr, pc, d] = patch.shape
pantie[120:120 + pr, :pc, :] = patch[::-1, ::-1]
front = pantie[:300, :350]
back = pantie[:-8, 300:][:, ::-1]
back = np.pad(back, [(0, 100), (0, 0), (0, 0)], 'constant')

arry = np.zeros(49)
arry[2:25] = np.sin(np.linspace(0, np.pi, 23)) * -10
arrx = (np.sin(np.linspace(-np.pi / 2, np.pi, 49)) + 1) * 11.5 - 35
arrx[:25] -= np.sin(np.linspace(0, np.pi / 2, 25)) * 4
arrx[-14:] += np.linspace(0, 1, 14)**2 * 20
front = affine_transform_by_arr(front, arrx, arry)
front = np.uint8(resize(front, [1.87, 1.87]) * 255)[:, 16:]
front = np.concatenate((front[:, ::-1], front), axis=1)

arry = np.linspace(0, 1, 49) * -10
arry[7:21] -= np.sin(np.linspace(0, np.pi / 2, 14)) * 20
arrx = np.linspace(0, 1, 49)**1.5 * 155 - 155
arrx[7:-7] -= np.sin(np.linspace(-np.pi, np.pi, 35)) * 6.5
arrx[:21] -= np.sin(np.linspace(0, np.pi / 2, 21)) * 5
back = affine_transform_by_arr(back, arrx, arry)
back = np.uint8(resize(back, [1.87, 1.87]) * 255)[:-50, 18:]
back = np.concatenate((back[:, ::-1], back), axis=1)
[fr, fc, d] = front.shape
[br, bc, d] = back.shape
shiftx = 45
shifty = 293
pantie = np.zeros((fr + br - shifty + 25, fc, d), dtype=np.uint8)
pantie[:fr, :fc] = front
pantie[shifty:shifty + br, shiftx:shiftx + bc] = alpha_brend(back, pantie[shifty:shifty + br, shiftx:shiftx + bc], back[:, :, -1] > 0.5)
pantie = np.bitwise_and(pantie, self.mask)
return Image.fromarray(pantie)

def pick_color(self, arr):
return np.mean(np.mean(arr, axis=0), axis=0)

def extract_bra_color(self, pantie):
front = pantie[20:100, 30:80, :3] / 255.0
front_shade = pantie[130:150, 0:40, :3] / 255.0
front_color = self.pick_color(front)
front_shade_color = self.pick_color(front_shade)
return front_color, front_shade_color

def gen_bra(self, image):
pantie = np.array(image)
front_color, front_shade_color = self.extract_bra_color(pantie)
center = pantie[20:170, -200:-15, :3][:, ::-1]
center = resize(center, [4.3, 4.3])
bra_center = np.copy(self.bra_center)
bra_center[1715:1715 + center.shape[0], 100:100 + center.shape[1], :3] = center * np.float32(bra_center[1715:1715 + center.shape[0], 100:100 + center.shape[1], :3] > 0)
bra = self.bra[:, :, :3] * front_color
bra_shade = np.float32(self.bra_shade[:, :, -1] > 0)[:, :, None] * front_shade_color
bra = alpha_brend(bra_center[:, :, :3], bra[:, :, :3], bra_center[:, :, 0] > 0.1)
bra = alpha_brend(bra_shade, bra, self.bra_shade_alpha)
bra = np.dstack((bra, self.bra[:, :, 0] > 0.8))
return Image.fromarray(np.uint8(np.clip(bra, 0, 1) * 255))

def gen_extra_using_shademap(self, image, shade):
pantie = np.array(image)
front_color, front_shade_color = self.extract_bra_color(pantie)
dst = np.zeros_like(shade) + 1.
dst = dst[:, :, :3] * front_color
dst_shade = np.float32(shade[:, :, -1] > 0)[:, :, None] * front_shade_color
dst = alpha_brend(dst_shade, dst, shade[:, :, -1])
dst = np.dstack((dst, dst[:, :, 0] > 0))
return Image.fromarray(np.uint8(np.clip(dst, 0, 1) * 255))

def gen_ribbon(self, image):
pantie = np.array(image)
ribbon = pantie[24:32, 15:27, :3] / 255.0
ribbon_color = self.pick_color(ribbon)
ribbon_shade = pantie[26:30, 12:15, :3] / 255.0
ribbon_shade_color = self.pick_color(ribbon_shade)
ribbon = self.ribbon[:, :, :3] * ribbon_color
ribbon_shade = np.float32(self.ribbon_shade > 0)[:, :, None] * ribbon_shade_color
ribbon = alpha_brend(ribbon_shade, ribbon, self.ribbon_shade)
ribbon = np.dstack((ribbon, self.ribbon[:, :, -1] > 0.5))
return Image.fromarray(np.uint8(ribbon * 255))

def patch(self, image, transparent=False):
pantie = self.convert(image)
if transparent:
patched = Image.new("RGBA", (4096, 4096))
else:
patched = self.body.copy()
patched = self.paste(patched, pantie, self.pantie_position)
patched = self.paste(patched, self.gen_bra(image), self.bra_position)
patched = self.paste(patched, self.gen_extra_using_shademap(image, self.pantie_extra_shade), self.pantie_extra_position)
patched = self.paste(patched, self.gen_extra_using_shademap(image, self.bra_extra_shade1), self.bra_extra_position1)
patched = self.paste(patched, self.gen_extra_using_shademap(image, self.bra_extra_shade2), self.bra_extra_position2)
if self.use_ribbon_mesh:
patched = self.paste(patched, self.gen_ribbon(image), self.ribbon_position)
return patched
3 changes: 3 additions & 0 deletions webapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
"sakurana":[
"with_bra"
],
"sephira":[
"use_ribbon_mesh"
],
"shaclo_winter":[
"with_bra"
],
Expand Down

0 comments on commit eac4def

Please sign in to comment.