基于补角度工具1.4版本的小补丁
首先感谢菜刀两把marsmana1大佬的src补角度工具,让我节省了很多处理src的时间。【易用工具】src补角度工具1.4更新,可清理角度头像
https://dfldata.cc/forum.php?mod=viewthread&tid=7149
(出处: deepfacelab中文网)
我在使用v1.4版本(也是目前论坛能找到的最新版)时,遇到了两个问题,一个是-inf和inf经常会重复包含-55、55角度的部分图片,无论是pitch还是yaw都是这样
另外在尝试点击右键预览时,如果有文件找不到(被删除或移动),则软件会直接闪退,导致等待大半天才处理好的角度分部又要重新跑。
针对这两个问题,我简单修改了下代码,目前来看是完美解决的。
此补丁解决以下两个问题:
1. 修复了极限角度-inf和inf可能会重复显示-55/55的图像的问题
2. 修复了点击右键时由于找不到文件而闪退的问题(改为在控制台窗口输出警告)
安装方式:直接覆盖到_internal文件夹即可
必须先安装菜刀两把marsmana1大佬的src补角度工具v1.4
注意,本补丁修改的文件均为补角度工具的源码,不会改变DFL的任何代码。
另外,我在打包文件中已经备份了补角度工具原本的代码文件,后缀_backup
具体修改内容如下:
1. _internal/facesets/UI/controls/facegrid.py:
修改__init__为:
def __init__(self) -> None:
QObject.__init__(self)
self.pitchlist=[]
for i,pitchtick in enumerate(pitchticks):
if math.isinf(pitchtick) and i==0:
maxpitch=float(pitchticks)-2.5
minpitch=pitchtick
elif math.isinf(pitchtick) and i!=0:
maxpitch=pitchtick
minpitch=float(pitchticks)+2.5
else:
minpitch=float(pitchtick)-2.5
maxpitch=float(pitchtick)+2.5
yawlist=[]
for j,yawtick in enumerate(yawticks):
if math.isinf(yawtick) and j==0:
minyaw=yawtick
maxyaw=float(yawticks)-2.5
elif math.isinf(yawtick) and j!=0:
minyaw=float(yawticks)+2.5
maxyaw=yawtick
else:
minyaw=float(yawtick)-2.5
maxyaw=float(yawtick)+2.5
srcfilepathlist=[]
srccout=0
dstfilepathlist=[]
dstcout=0
item=
yawlist.append(item)
self.pitchlist.append(yawlist)
#moveToThread必须放后面,否则信号连接不正常
self.mainThread = QtCore.QThread()
self.moveToThread(self.mainThread)
#self.mainThread.started.connect(self._qthread_drop_paths_from_startpage)
#self.mainThread.finished.connect(self.slot_mainThread_finished)
self.mainThread.started.connect(self.load_AlignedThread)
2. _internal/facesets/UI/Ui_previewUI.py:
修改loadList为:
def loadList(self,obj):
=obj
if pitchtick<0:
ptx="低头"+str(round((0-pitchtick), 2))+'度'
elif pitchtick>0:
ptx="抬头"+str(round(pitchtick,2))+'度'
else:
ptx="平视0度"
self.label_pitch_valueL.setText(ptx)
if yawtick<0:
ytx="脸部右转"+str(round((0-yawtick), 2))+'度'
elif yawtick>0:
ytx="脸部左转"+str(round(yawtick,2))+'度'
else:
ytx="正向0度"
self.label_yaw_valueL.setText(ytx)
# Handle srcfilepathlist
for imgpath in self.srcfilepathlist:
try:
img = cv2.imdecode(numpy.fromfile(imgpath, dtype=numpy.uint8), -1)
if img is not None:
itemname = Path(imgpath).stem
self.add_item_to_Qlistwiget_safety(self.listWidget_main, itemname, img, tootip=str(imgpath))
except FileNotFoundError:
print(f"Warning: File not found {imgpath}")
except Exception as e:
print(f"Error loading image {imgpath}: {str(e)}")
# Handle dstfilepathlist
for imgpath1 in self.dstfilepathlist:
try:
img = cv2.imdecode(numpy.fromfile(imgpath1, dtype=numpy.uint8), -1)
if img is not None:
itemname = Path(imgpath1).stem
self.add_item_to_Qlistwiget_safety(self.listWidget_second, itemname, img, tootip=str(imgpath1))
except FileNotFoundError:
print(f"Warning: File not found {imgpath1}")
except Exception as e:
print(f"Error loading image {imgpath1}: {str(e)}")
if self.srcfilepathlist is None or len(self.srcfilepathlist)==0:
self.pushButton_main_delsel.setDisabled(True)
self.pushButton_main_copyall.setDisabled(True)
self.pushButton_main_copysel.setDisabled(True)
if self.dstfilepathlist is None or len(self.dstfilepathlist)==0:
self.pushButton_sec_delsel.setDisabled(True)
self.pushButton_sec_copyall.setDisabled(True)
self.pushButton_sec_copysel.setDisabled(True)
3. _internal/facesets/UI/Ui_FaceGrid.py:
修改slot_gridrightClicked为:
def slot_gridrightClicked(self, x, y):
if not self.checkBox_rightClick.isChecked():
return
keyname = str(x) + '_' + str(y)
item = self.facesgrid.getFullInfo(x, y)
= item
# Exit early if there are no files to process
if len(srcfilepathlist) == 0 and len(dstfilepathlist) == 0:
return
try:
# Create and display the preview dialog
previewdlg = previewDlgClass()
MainWindow = QtWidgets.QDialog()
previewdlg.setupUi(MainWindow)
previewdlg.loadList(item)# Make sure loadList can handle exceptions gracefully
MainWindow.exec_()
except Exception as e:
print(f"Error during preview dialog execution: {str(e)}")
# Optionally provide a user-friendly error message or log the error appropriately
# Reload face info into the frame, ensure this call is safe
try:
self.frame.loadfacesinfo(self.facesgrid)
except Exception as e:
print(f"Error reloading face info: {str(e)}")
非常感谢,很好用,已经用上了 感谢无私分享 奈何本人没文化,一句卧槽行天下 棒棒的 支持
页:
[1]