已添加坐标clamp,确保归一化后的x和y严格在0.0到1.0之间。
This commit is contained in:
parent
d06b96ece1
commit
f245d972c2
@ -462,13 +462,13 @@ class YOLOSegmentationInference:
|
||||
h, w = mask.shape
|
||||
points = []
|
||||
for point in approx:
|
||||
x = point[0][0] / w
|
||||
y = point[0][1] / h
|
||||
x = max(0.0, min(1.0, point[0][0] / w))
|
||||
y = max(0.0, min(1.0, point[0][1] / h))
|
||||
points.extend([x, y])
|
||||
|
||||
# 写入标签文件
|
||||
if len(points) >= 6: # 至少3个点
|
||||
line = f"{class_id} {' '.join(map(lambda x: f'{x:.6f}', points))} {score:.6f}\n"
|
||||
line = f"{class_id} {' '.join(map(lambda x: f'{x:.6f}', points))}\n"
|
||||
f.write(line)
|
||||
|
||||
print(f"标签文件已保存: {label_path}")
|
||||
@ -1027,4 +1027,8 @@ def predict_images_share_dir(task_id, pt_name, zip_url, user_name, pwd, output_d
|
||||
else :
|
||||
print(f"错误: 输入 {zip_url} 不是有效的文件或目录")
|
||||
|
||||
return standardized_path(f"{target_path}_识别/{task_id}/{current_time}/{task_id}.zip"), "success"
|
||||
return standardized_path(f"{target_path}_识别/{task_id}/{current_time}/{task_id}.zip"), "success"
|
||||
|
||||
if __name__ == '__main__':
|
||||
predict_images
|
||||
#predict_images_share_dir(1, "road_crack", "smb://192.168.1.100/share/ai_train_platform/train.zip", "admin", "admin.123", "predictions", 0.25, True)
|
||||
Loading…
x
Reference in New Issue
Block a user