Добавлены пропсы конвейера и стереодвижки, задействованные в прогоне

assets/conveyors (274 МБ) - ленты и угловая секция NVIDIA, на которые ссылается сцена
относительным путём. Раньше исключались как перекачиваемые, но без них сцена не
композится из коробки.

cv/ - код стереодвижков, которые вызывает control_test, без весов:
* defom-stereo - рабочий бейзлайн (DEFOM vitl, вход 480, iters 24)
* crestereo - второй движок, точнее по габаритам (MAE 23.5 против 32.8 мм)
* fast-foundationstereo - проверялся, в бейзлайн не вошёл
* circular_section.py - показатель кругового сечения, перенесён в measure_plane.py:
  выравнивает облако по СОБСТВЕННЫМ главным осям и режет на пяти высотах вдоль каждой.
  Три самодельные версии (мировые оси, одно сечение) давали хуже; результаты проверки
  на эталонной геометрии - в circular_section_results.json

Веса по-прежнему не в репозитории - источники в MODELS.md. Наборы кадров прежних
прогонов (cv/flow_*, 1.26 ГБ) исключены: это выход, а не исходники.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dasha_f
2026-08-01 13:12:07 +00:00
parent 0d32f32db0
commit 6e1a22ba8b
184 changed files with 17666 additions and 3 deletions
+78
View File
@@ -0,0 +1,78 @@
import numpy as np
import cv2
import onnxruntime
# Ref: https://github.com/megvii-research/CREStereo/blob/master/test.py
def inference(left, right, model, no_flow_model):
# Get onnx model layer names (see convert_to_onnx.py for what these are)
input1_name = model.get_inputs()[0].name
input2_name = model.get_inputs()[1].name
input3_name = model.get_inputs()[2].name
output_name = model.get_outputs()[0].name
# Decimate the image to half the original size for flow estimation network
imgL_dw2 = cv2.resize(
left, (left.shape[1] // 2, left.shape[0] // 2), interpolation=cv2.INTER_LINEAR)
imgR_dw2 = cv2.resize(
right, (right.shape[1] // 2, right.shape[0] // 2), interpolation=cv2.INTER_LINEAR)
# Reshape inputs to match what is expected
imgL = left.transpose(2, 0, 1)
imgR = right.transpose(2, 0, 1)
imgL = np.ascontiguousarray(imgL[None, :, :, :]).astype("float32")
imgR = np.ascontiguousarray(imgR[None, :, :, :]).astype("float32")
imgL_dw2 = imgL_dw2.transpose(2, 0, 1)
imgR_dw2 = imgR_dw2.transpose(2, 0, 1)
imgL_dw2 = np.ascontiguousarray(imgL_dw2[None, :, :, :]).astype("float32")
imgR_dw2 = np.ascontiguousarray(imgR_dw2[None, :, :, :]).astype("float32")
print("Model Forwarding...")
# First pass it just to get the flow
pred_flow_dw2 = no_flow_model.run(
[output_name], {input1_name: imgL_dw2, input2_name: imgR_dw2})[0]
# Second pass gets us the disparity
pred_disp = model.run([output_name], {
input1_name: imgL, input2_name: imgR, input3_name: pred_flow_dw2})[0]
return np.squeeze(pred_disp[:, 0, :, :])
if __name__ == '__main__':
left_img = cv2.imread("left.png")
right_img = cv2.imread("right.png")
in_h, in_w = left_img.shape[:2]
# Resize images
eval_h, eval_w = (in_h, in_w)
assert eval_h % 8 == 0, "input height should be divisible by 8"
assert eval_w % 8 == 0, "input width should be divisible by 8"
imgL = cv2.resize(left_img, (eval_w, eval_h),
interpolation=cv2.INTER_LINEAR)
imgR = cv2.resize(right_img, (eval_w, eval_h),
interpolation=cv2.INTER_LINEAR)
no_flow_model_path = "models/crestereo_without_flow.onnx"
model_path = "models/crestereo.onnx"
model = onnxruntime.InferenceSession(model_path)
no_flow_model = onnxruntime.InferenceSession(no_flow_model_path)
pred = inference(imgL, imgR, model, no_flow_model)
t = float(in_w) / float(eval_w)
disp = cv2.resize(pred, (eval_w, eval_h),
interpolation=cv2.INTER_LINEAR) * t
disp_vis = (disp - disp.min()) / (disp.max() - disp.min()) * 255.0
disp_vis = disp_vis.astype("uint8")
disp_vis = cv2.applyColorMap(disp_vis, cv2.COLORMAP_INFERNO)
combined_img = np.hstack((left_img, disp_vis))
cv2.namedWindow("output", cv2.WINDOW_NORMAL)
cv2.imshow("output", combined_img)
cv2.imwrite("output.jpg", disp_vis)
cv2.waitKey(0)