Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run test.py without matlab #4

Open
Embrace-Arch opened this issue Feb 16, 2025 · 0 comments
Open

how to run test.py without matlab #4

Embrace-Arch opened this issue Feb 16, 2025 · 0 comments

Comments

@Embrace-Arch
Copy link

you only change the align.py
def align_fp(boundary, boxes, types, edges, image, threshold, dtype=int):
"""
Python 实现的 align_fp 函数,移除对 MATLAB 的依赖。

参数:
    boundary: 房间边界的坐标。
    boxes: 房间的边界框。
    types: 房间的类型。
    edges: 房间之间的连接关系。
    image: 输入图像数据(如果有)。
    threshold: 阈值,用于对齐逻辑。
    dtype: 数据类型。

返回:
    boxes_aligned: 对齐后的边界框。
    order: 对齐后的顺序。
    room_boundaries: 房间边界的多边形表示。
"""
# 转换为 NumPy 数组
boundary = np.array(boundary, dtype=dtype)
boxes = np.array(boxes, dtype=dtype)
types = np.array(types, dtype=dtype)
edges = np.array(edges, dtype=dtype)
image = np.array(image, dtype=dtype)

# 示例对齐逻辑(根据实际需求替换)
# 假设对齐逻辑是根据 threshold 调整 boxes 的大小和位置
boxes_aligned = boxes.copy()
for i in range(len(boxes)):
    boxes_aligned[i] = boxes[i] + threshold  # 简单示例逻辑:增加阈值

# 示例顺序逻辑(根据房间类型排序)
order = np.argsort(types)  # 根据房间类型排序

# 示例房间边界逻辑(简单模拟边界处理)
room_boundaries = [boundary + np.random.rand(*boundary.shape) * 0.1 for _ in range(len(boxes))]

return boxes_aligned, order, room_boundaries

def align_fp_gt(boundary, boxes, types, edges, dtype=int):
"""
对齐 Ground Truth (GT) 数据。
"""
GT_THRESHOLD = 6
PRED_ThRESHOLD = 12
REFINE_ThRESHOLD = 18
return align_fp(boundary, boxes, types, edges, [], GT_THRESHOLD, dtype)

def align_fp_gt2(boundary, boxes, types, edges, dtype=int):
"""
对齐 Ground Truth (GT) 数据的另一种实现。
"""
GT_THRESHOLD = 6
PRED_ThRESHOLD = 12
REFINE_ThRESHOLD = 18
return align_fp(boundary, boxes, types, edges, [], GT_THRESHOLD, dtype)

def align_fp_coarse(boundary, boxes, types, edges, dtype=int):
"""
对齐预测数据 (Coarse Alignment)。
"""
GT_THRESHOLD = 6
PRED_ThRESHOLD = 12
REFINE_THRESHOLD = 18
return align_fp(boundary, boxes, types, edges, [], PRED_THRESHOLD, dtype)

def align_fp_fine(boundary, boxes, types, edges, image, dtype=int):
"""
对齐精细预测数据 (Fine Alignment)。
"""
GT_THRESHOLD = 6
PRED_ThRESHOLD = 12
REFINE_THRESHOLD = 18
return align_fp(boundary, boxes, types, edges, image, REFINE_THRESHOLD, dtype)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant