新增选项:1.避免模式3跳过人脸识别 2.避免对有码封面进行人脸识别
This commit is contained in:
@@ -55,16 +55,22 @@ def face_crop_height(filename, width, height):
|
|||||||
return (0, 0, width, cropHeight)
|
return (0, 0, width, cropHeight)
|
||||||
|
|
||||||
|
|
||||||
def cutImage(imagecut, path, fanart_path, poster_path):
|
def cutImage(imagecut, path, fanart_path, poster_path, skip_facerec=False):
|
||||||
fullpath_fanart = os.path.join(path, fanart_path)
|
fullpath_fanart = os.path.join(path, fanart_path)
|
||||||
fullpath_poster = os.path.join(path, poster_path)
|
fullpath_poster = os.path.join(path, poster_path)
|
||||||
if config.getInstance().download_only_missing_images() and not file_not_exist_or_empty(fullpath_poster):
|
if config.getInstance().face_aways_imagecut():
|
||||||
|
imagecut = 1
|
||||||
|
elif config.getInstance().download_only_missing_images() and not file_not_exist_or_empty(fullpath_poster):
|
||||||
return
|
return
|
||||||
if imagecut == 1: # 剪裁大封面
|
if imagecut == 1: # 剪裁大封面
|
||||||
try:
|
try:
|
||||||
img = Image.open(fullpath_fanart)
|
img = Image.open(fullpath_fanart)
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
if width/height > 2/3: # 如果宽度大于2
|
if width/height > 2/3: # 如果宽度大于2
|
||||||
|
if skip_facerec:
|
||||||
|
# 有码封面默认靠右切
|
||||||
|
img2 = img.crop((width - int(height/3) * 2, 0, width, height))
|
||||||
|
else:
|
||||||
# 以人像为中心切取
|
# 以人像为中心切取
|
||||||
img2 = img.crop(face_crop_width(fullpath_fanart, width, height))
|
img2 = img.crop(face_crop_width(fullpath_fanart, width, height))
|
||||||
elif width/height < 2/3: # 如果高度大于3
|
elif width/height < 2/3: # 如果高度大于3
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ vars=outline,series,studio,tag,title
|
|||||||
[javdb]
|
[javdb]
|
||||||
sites=38,39
|
sites=38,39
|
||||||
|
|
||||||
; 人脸识别 hog:方向梯度直方图(不太准确,速度快) cnn:深度学习模型(准确,需要GPU/CUDA,速度慢)
|
; 人脸识别 locations_model=hog:方向梯度直方图(不太准确,速度快) cnn:深度学习模型(准确,需要GPU/CUDA,速度慢)
|
||||||
|
; uncensored_only=0:对全部封面进行人脸识别 1:只识别无码封面,有码封面直接切右半部分
|
||||||
|
; aways_imagecut=0:按各网站默认行为 1:总是裁剪封面,开启此项将无视[common]download_only_missing_images=1总是覆盖封面
|
||||||
[face]
|
[face]
|
||||||
locations_model=hog
|
locations_model=hog
|
||||||
|
uncensored_only=1
|
||||||
|
aways_imagecut=0
|
||||||
|
|||||||
22
config.py
22
config.py
@@ -346,22 +346,20 @@ class Config:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def cc_convert_vars(self) -> str:
|
def cc_convert_vars(self) -> str:
|
||||||
try:
|
return self.conf.get("cc_convert", "vars",
|
||||||
return self.conf.get("cc_convert", "vars")
|
fallback="actor,director,label,outline,series,studio,tag,title")
|
||||||
except:
|
|
||||||
return "actor,director,label,outline,series,studio,tag,title"
|
|
||||||
|
|
||||||
def javdb_sites(self) -> str:
|
def javdb_sites(self) -> str:
|
||||||
try:
|
return self.conf.get("javdb", "sites", fallback="38,39")
|
||||||
return self.conf.get("javdb", "sites")
|
|
||||||
except:
|
|
||||||
return "33,34"
|
|
||||||
|
|
||||||
def face_locations_model(self) -> str:
|
def face_locations_model(self) -> str:
|
||||||
try:
|
return self.conf.get("face", "locations_model", fallback="hog")
|
||||||
return self.conf.get("face", "locations_model")
|
|
||||||
except:
|
def face_uncensored_only(self) -> bool:
|
||||||
return "hog"
|
return self.conf.getboolean("face", "uncensored_only", fallback=True)
|
||||||
|
|
||||||
|
def face_aways_imagecut(self) -> bool:
|
||||||
|
return self.conf.getboolean("face", "aways_imagecut", fallback=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _exit(sec: str) -> None:
|
def _exit(sec: str) -> None:
|
||||||
|
|||||||
4
core.py
4
core.py
@@ -717,7 +717,7 @@ def core_main(file_path, number_th, oCC):
|
|||||||
|
|
||||||
|
|
||||||
# 裁剪图
|
# 裁剪图
|
||||||
cutImage(imagecut, path, fanart_path, poster_path)
|
cutImage(imagecut, path, fanart_path, poster_path, bool(conf.face_uncensored_only() and not uncensored))
|
||||||
|
|
||||||
# 添加水印
|
# 添加水印
|
||||||
if conf.is_watermark():
|
if conf.is_watermark():
|
||||||
@@ -760,7 +760,7 @@ def core_main(file_path, number_th, oCC):
|
|||||||
extrafanart_download(json_data.get('extrafanart'), path, number, filepath)
|
extrafanart_download(json_data.get('extrafanart'), path, number, filepath)
|
||||||
|
|
||||||
# 裁剪图
|
# 裁剪图
|
||||||
cutImage(imagecut, path, fanart_path, poster_path)
|
cutImage(imagecut, path, fanart_path, poster_path, bool(conf.face_uncensored_only() and not uncensored))
|
||||||
|
|
||||||
# 添加水印
|
# 添加水印
|
||||||
if conf.is_watermark():
|
if conf.is_watermark():
|
||||||
|
|||||||
Reference in New Issue
Block a user