Skip to content

Commit

Permalink
Merge pull request #2 from ChasonJiang/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
ChasonJiang authored Dec 21, 2023
2 parents 7f82df4 + 15545b0 commit 145542b
Show file tree
Hide file tree
Showing 25 changed files with 181 additions and 136 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ test/*
__pycache__/*
visualization/*.json
.vscode/*
/**/__pycache__/*.pyc
src/__pycache__
src/weights/*
20 changes: 12 additions & 8 deletions Facial.Data.Extractor.Multifile.spec → FDE.Multifile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ a = Analysis(
['Launcher.py'],
pathex=[],
binaries=[],
datas=[("C:\\Users\\14404\\.virtualenvs\\Extractor-PieuWTZ6\\Lib\\site-packages\\onnxruntime\\capi","onnxruntime\\capi"),
("src\\models\\hrnet_face.onnx","src\\models"),
("src\\models\\hrnet_eyes.onnx","src\\models"),
("C:\\Users\\14404\\.virtualenvs\\Extractor-PieuWTZ6\\Lib\\site-packages\\\mtcnn_ort\\onet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\.virtualenvs\\Extractor-PieuWTZ6\\Lib\\site-packages\\\mtcnn_ort\\pnet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\.virtualenvs\\Extractor-PieuWTZ6\\Lib\\site-packages\\\mtcnn_ort\\rnet.onnx","mtcnn_ort")
datas=[("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\onnxruntime\\capi","onnxruntime\\capi"),
("src\\weights\\HRNet.onnx","src\\weights"),
("src\\weights\\FDENet_face.onnx","src\\weights"),
("src\\weights\\FDENet_eyes.onnx","src\\weights"),
("src\\weights\\FDENet_nose.onnx","src\\weights"),
("src\\weights\\FDENet_mouth.onnx","src\\weights"),
("src\\version","src"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\onet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\pnet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\rnet.onnx","mtcnn_ort")
],
hiddenimports=[],
hookspath=[],
Expand All @@ -32,7 +36,7 @@ exe = EXE(
a.scripts,
[],
exclude_binaries=True,
name='Facial Data Extractor',
name='FDE',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand All @@ -52,5 +56,5 @@ coll = COLLECT(
strip=False,
upx=True,
upx_exclude=[],
name='Launcher',
name='FDE',
)
54 changes: 54 additions & 0 deletions FDE.Singlefile.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
['Launcher.py'],
pathex=[],
binaries=[],
datas=[("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\onnxruntime\\capi","onnxruntime\\capi"),
("src\\weights\\HRNet.onnx","src\\weights"),
("src\\weights\\FDENet_face.onnx","src\\weights"),
("src\\weights\\FDENet_eyes.onnx","src\\weights"),
("src\\weights\\FDENet_nose.onnx","src\\weights"),
("src\\weights\\FDENet_mouth.onnx","src\\weights"),
("src\\version","src"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\onet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\pnet.onnx","mtcnn_ort"),
("C:\\Users\\14404\\anaconda3\\envs\\extractor\\Lib\\site-packages\\mtcnn_ort\\rnet.onnx","mtcnn_ort")
],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='FDE',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
50 changes: 0 additions & 50 deletions Facial.Data.Extractor.Singlefile.spec

This file was deleted.

6 changes: 3 additions & 3 deletions VersionInfo.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Version":"1.2.2",
"UpdateInfo":"1. 更新了面部数据提取模型\n2. 改进了面部和眼部的特征相似度\n3. 1.2.0版本及以下建议更新!\n4. 加入AI捏脸交流群,免费领取人物卡。链接:https://afdian.net/item/448380d223b311ee8c9752540025c377",
"Version":"2.0.0",
"UpdateInfo":"0. 喜报!你关注的UP主终于更新软件啦!该版本强烈建议更新!\n1. 更新了自研的面部数据提取模型\n2. 改善了面部轮廓、眼睛、鼻子、嘴唇的特征相似度\n3. 可同时选择多张图片进行推理;\n4. 修复了无法连接服务器时的闪退问题。\n",
"Download":{
"Github":"https://github.com/ChasonJiang/Facial-Data-Extractor/releases/latest",
"BaiduNetDisk":"https://pan.baidu.com/s/1WSTzlX6bLuRahuxxDQih3A?pwd=fhuz"
},
"Notice":"加入AI捏脸交流群,免费领取人物卡。\n链接:\nhttps://afdian.net/item/448380d223b311ee8c9752540025c377"
"Notice":"加入官方AI捏脸交流群,免费领取人物卡。\n链接:\nhttps://afdian.net/item/448380d223b311ee8c9752540025c377"
}
7 changes: 3 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# 介绍
欢迎使用 Facial Data Extractor
本软件旨在利用AI从人物图像中提取人脸数据,用于辅助Illusion系列游戏中的人物捏脸。
目前,只支持 AI Shoujo 和 Honey Select2。
如果你想知道使用了什么技术路线,[请看这里](https://github.com/ChasonJiang/Extract-Face-Data)
欢迎使用 Facial Data Extractor
本软件旨在利用AI从人物图像中提取人脸数据,用于辅助Illusion系列游戏中的人物捏脸。
目前,只支持 AI Shoujo 和 Honey Select2。

# 使用教程:
- Step1. 点击“打开图片”按钮, 选择图片。
Expand Down
Binary file added req.txt
Binary file not shown.
53 changes: 32 additions & 21 deletions src/ExtractorWindow.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import os
import traceback
from .Extractor import Extractor
from .OnnxExtractor import OnnxExtractor
from PyQt5.QtCore import QUrl,pyqtSignal
from PyQt5.QtWidgets import QWidget,QFileDialog
from .ExtractorWindow_UI import Ui_Extractor
from .Processor import Processor
from .VersionChecker import VersionChecker

import onnxruntime
class ExtractorWindow(QWidget,Ui_Extractor):
chekversion_signal = pyqtSignal()
def __init__(self, parent: QWidget | None=None) -> None:
Expand All @@ -16,10 +16,11 @@ def __init__(self, parent: QWidget | None=None) -> None:

self.openBtn.clicked.connect(self.openImage)
self.extractBtn.clicked.connect(self.process)
self.img_path = None
self.save_path = None
self.img_path:list = []
# self.save_path = None
self.extractor=None
self.version="1.2.2"
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)),"version"),"r") as f:
self.version=f.read()
self.hello()
self.chekversion_signal.connect(self.checkVersion)
self.chekversion_signal.emit()
Expand All @@ -36,6 +37,8 @@ def checkVersion(self):
def printVersionInfo(self,info:dict):
if not info["State"]:
self.log(info["msg"])
return

if self.version == info["Version"]:
self.log("已是最新版本!\n")
else:
Expand All @@ -53,36 +56,37 @@ def loadExtractor(self,):
return True

try:
self.extractor = Extractor()
self.extractor = OnnxExtractor()
except:
self.log(traceback.format_exc())
self.log("Extractor 加载失败!\n")
return False

self.log("Extractor 加载成功!\n")
self.log(f'Use onnxruntime backend: {onnxruntime.get_device()}, Available Providers:{onnxruntime.get_available_providers()}\n')
return True

def hello(self,):
self.log(f'''
\t\t欢迎使用 Facial Data Extractor
\t\t欢迎使用 Facial Data Extractor (FDE)
本软件利用AI从人物图像中提取人脸数据,用于辅助Illusion系列游戏中的人物捏脸。
目前,只支持 AI Shoujo 和 Honey Select2。
作者:ChasonJiang
Github:https://github.com/ChasonJiang/Face-Data-Extractor
Github:https://github.com/ChasonJiang/Facial-Data-Extractor
https://github.com/ChasonJiang/FDE
当前版本:{self.version}
使用教程:
Step1. 点击“打开图片”按钮, 选择图片。
Step1. 点击“打开图片”按钮, 选择图片,可选择多张
Step2. 点击“提取”按钮, 等待提取面部数据。
Step3. 使用记事本或任意编辑器,打开提取完毕的json文件。
注意事项:
1. 脸型可以使用官方的三种脸型,“类型1、类型2、类型3”,其他脸型请自测。
2. 现在阶段仅支持女性角色,男性角色自测。
3. 现阶段AI并不能完美“复刻”人脸,仍需部分微调。
4. 一般情况下,捏脸完成后需要微调一下,“眼”部分的“眼宽2”、“眼角Z轴”、“眼皮形状2”,“鼻子”部分视情况而定。
捐赠:
欢迎访问下方链接进行捐赠支持,你的支持是我最大的动力,谢谢!
Expand All @@ -95,14 +99,17 @@ def hello(self,):

def openImage(self,):
# QDialog(self).show()
self.img_path = []
if not self.openBtn.isEnabled():
return
try:
img_url,_=QFileDialog.getOpenFileUrl(self,"选择图片",QUrl(""),"Image(*.jpg;*.jpeg;*.png)")
if img_url.url()=="":
return
self.img_path=img_url.url().split("///")[1]
self.log(f"已选择图片: {self.img_path}\n")
img_urls,_=QFileDialog.getOpenFileUrls(self,"选择图片",QUrl(""),"Image(*.jpg;*.jpeg;*.png)")
for img_url in img_urls:
if img_url.url()=="":
self.img_path.append(None)
else:
self.img_path.append(img_url.url().split("///")[1])
self.log(f"已选择{len(self.img_path)}张图片: {self.img_path}\n")
except:
self.log(f"图片选择失败!\n")
self.extractBtn.setDisabled(True)
Expand All @@ -114,18 +121,22 @@ def openImage(self,):
# img=cv2.imdecode(np.fromfile(img_path,dtype=np.uint8),-1)

def process(self,):
if self.img_path is None:
if self.img_path is []:
self.log(f"请选择图片!\n")
return
save_path=[]
# self.log(f"正在提取,请稍等...\n")
self.openBtn.setDisabled(True)
img_path_splited = self.img_path.split(os.sep)
img_name = img_path_splited[-1].split(".")[0]
dir = os.sep.join(img_path_splited[:-1])
self.save_path = os.path.join(dir,f"{img_name}.json")
for item in self.img_path:
img_path_splited = item.split(os.sep)
img_name = img_path_splited[-1].split(".")[0]
dir = os.sep.join(img_path_splited[:-1])
save_path.append(os.path.join(dir,f"{img_name}.json"))

if not self.loadExtractor():
return

processor=Processor(self.extractor ,self.img_path,self.save_path)
processor=Processor(self.extractor ,self.img_path,save_path)
processor.done_signal.connect(self.process_done)
processor.log_signal.connect(self.log)
processor.finished.connect(lambda :processor.done_signal.disconnect())
Expand Down
Loading

0 comments on commit 145542b

Please sign in to comment.