新增选项:1.避免模式3跳过人脸识别 2.避免对有码封面进行人脸识别
This commit is contained in:
@@ -55,18 +55,24 @@ def face_crop_height(filename, width, height):
|
||||
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_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
|
||||
if imagecut == 1: # 剪裁大封面
|
||||
try:
|
||||
img = Image.open(fullpath_fanart)
|
||||
width, height = img.size
|
||||
if width/height > 2/3: # 如果宽度大于2
|
||||
# 以人像为中心切取
|
||||
img2 = img.crop(face_crop_width(fullpath_fanart, width, height))
|
||||
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))
|
||||
elif width/height < 2/3: # 如果高度大于3
|
||||
# 从底部向上切割
|
||||
img2 = img.crop(face_crop_height(fullpath_fanart, width, height))
|
||||
|
||||
@@ -119,6 +119,10 @@ vars=outline,series,studio,tag,title
|
||||
[javdb]
|
||||
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]
|
||||
locations_model=hog
|
||||
uncensored_only=1
|
||||
aways_imagecut=0
|
||||
|
||||
22
config.py
22
config.py
@@ -346,22 +346,20 @@ class Config:
|
||||
return 1
|
||||
|
||||
def cc_convert_vars(self) -> str:
|
||||
try:
|
||||
return self.conf.get("cc_convert", "vars")
|
||||
except:
|
||||
return "actor,director,label,outline,series,studio,tag,title"
|
||||
return self.conf.get("cc_convert", "vars",
|
||||
fallback="actor,director,label,outline,series,studio,tag,title")
|
||||
|
||||
def javdb_sites(self) -> str:
|
||||
try:
|
||||
return self.conf.get("javdb", "sites")
|
||||
except:
|
||||
return "33,34"
|
||||
return self.conf.get("javdb", "sites", fallback="38,39")
|
||||
|
||||
def face_locations_model(self) -> str:
|
||||
try:
|
||||
return self.conf.get("face", "locations_model")
|
||||
except:
|
||||
return "hog"
|
||||
return self.conf.get("face", "locations_model", fallback="hog")
|
||||
|
||||
def face_uncensored_only(self) -> bool:
|
||||
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
|
||||
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():
|
||||
@@ -760,7 +760,7 @@ def core_main(file_path, number_th, oCC):
|
||||
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():
|
||||
|
||||
Reference in New Issue
Block a user