更新阈值计算方式
This commit is contained in:
+9
-2
@@ -479,6 +479,13 @@ class VideoCutFromDir:
|
||||
return {
|
||||
"required": {
|
||||
"frame_dir": ("STRING", {"default": None}),
|
||||
"threshold": ("FLOAT", {
|
||||
"default": 0.5,
|
||||
"min": 0.01,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
"display": "number"
|
||||
}),
|
||||
"min_frame": ("INT", {
|
||||
"default": 16,
|
||||
"min": 1,
|
||||
@@ -501,8 +508,8 @@ class VideoCutFromDir:
|
||||
|
||||
CATEGORY = "badger"
|
||||
|
||||
def video_cut_from_dir(self, frame_dir, min_frame, max_frame):
|
||||
cutList = getCutList(frame_dir, min_frame, max_frame)
|
||||
def video_cut_from_dir(self, frame_dir,threshold, min_frame, max_frame):
|
||||
cutList = getCutList(frame_dir,threshold, min_frame, max_frame)
|
||||
dirPathString = cutToDir(frame_dir, cutList)
|
||||
|
||||
return (dirPathString,)
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ def calculate_image_similarity(img_path1, img_path2):
|
||||
return combined_score
|
||||
|
||||
|
||||
def getCutList(imagePath, min_frame, max_frame):
|
||||
def getCutList(imagePath, threshold, min_frame, max_frame):
|
||||
pngList = os.listdir(imagePath)
|
||||
cutList = []
|
||||
indexList = []
|
||||
@@ -51,13 +51,13 @@ def getCutList(imagePath, min_frame, max_frame):
|
||||
imgPath0 = os.path.join(imagePath, pngList[i])
|
||||
imgPath1 = os.path.join(imagePath, pngList[i + 1])
|
||||
similarity = calculate_image_similarity(imgPath0, imgPath1)
|
||||
print("切割画面(" + str(i + 1) + "/" + str(len(pngList) - 1) +") 相似度:"+ str(similarity))
|
||||
print("切割画面(" + str(i + 1) + "/" + str(len(pngList) - 1) + ") 相似度:" + str(similarity))
|
||||
indexList.append(i)
|
||||
resList.append(similarity)
|
||||
i += 1
|
||||
|
||||
i = min_frame - 1
|
||||
threshold = sum(resList)/len(resList)
|
||||
threshold = (sum(resList) / len(resList)) * threshold
|
||||
while i < len(pngList) - 1:
|
||||
if num >= max_frame:
|
||||
num = 0
|
||||
|
||||
Reference in New Issue
Block a user