Mesh-gpt(点处理、保存脚本,Transformer)
小结:
1、配置了学长的环境,并编写点处理(旋转、镜像)和保存(由内存numpy数组到shp文件)脚本。
2、初步阅读mesh-gpt论文,思考Transformer网络架构(翻译模型和补全模型的训练区别)
环境配置#
pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118

pip install git+https://github.com/peng0817-3dv/floorplan-reconsturtion-based-plane-triangle.git

pip list

安装缺少的库
pip install pytest
pip install matplotlib
1、尝试运行test/load_shp_test.py
,报错
添加
成功运行test/load_shp_test.py
,并生成load_shp_test
目录结果
数据增强#
faces和edges存的是vertices的索引(face是三个点+置信度信息;edge是两个点+置信度信息),也就是说face和edge本身并不包含任何位置信息,有位置的是vertices的坐标。
数据结构
vertices = [(x1, y1), (x2, y2), ...]
vertices_confidence = [pv1, pv2, ...]
edges = [(1, 0), (15, 1), ...] #边的两端点序号
edges_confidence = [ev1, ev2, ...]
point_id_to_edges_id = { point1_id : [edge1_id,edge2_id,...], point2_id:[...] }
faces = [(15, 1, 0), (39, 60, 38), ...] # 边的三端点序号
faces_confidences = [ef1, ef2, ...]
faces_label = [-1, -1, ...]
所以生成旋转/翻转的数据(数据增强)实际上是对点集vertices的处理
原始点集

在加载点的函数get_vertices_data
中对点进行90度旋转
在二维空间中,绕原点逆时针旋转一个角度θ的变换可以用以下公式表示:
新的x' = x * cos(θ) - y * sin(θ)
新的y' = x * sin(θ) + y * cos(θ)对于90度的旋转(θ = 90° 或 π/2 弧度),cos(π/2) = 0 且 sin(π/2) = 1,所以变换公式简化为:
新的x' = -y
新的y' = x
结果(左侧为原始的,右侧为旋转90度)
封装函数
定义rotate_vertices
对点进行旋转,旋转角度(90 / 180 / 270)
定义mirror_vertices
对点进行镜像,镜像轴(x / y)
def rotate_vertices(vertices, angle):
"""
对点进行旋转
:param vertices:
:param angle: 旋转角度(90 / 180 / 270)
:return:
"""
if angle == 90:
rotated_vertices = [(-y, x) for x, y in vertices]
elif angle == 180:
rotated_vertices = [(-x, -y) for x, y in vertices]
elif angle == 270:
rotated_vertices = [(y, -x) for x, y in vertices]
return rotated_vertices
def mirror_vertices(vertices, axis):
"""
对点进行镜像
:param vertices:
:param axis: 镜像轴(x / y)
:return:
"""
if axis == 'x':
mirrored_vertices = [(x, -y) for x, y in vertices]
elif axis == 'y':
mirrored_vertices = [(-x, y) for x, y in vertices]
return mirrored_vertices
只需要加载点后备份并进行vertices变换便可得到增强的数据
疑问:点的置信度、边的置信度和面的置信度是什么意思,后者是否可以由前者得到
比如一条边有两个点,一个面有三个边(三个点),边/面的置信度是怎么算的?和点的置信度有什么关联?
数据保存#
编写保存脚本save_shp.py
,实现从gpu中的数据obj_datas保存回shp文件
-
运行
save_shp.py/
的test,实现加载数据到obj_datas并保存成shp文件 -
运行
load_shp.py
, 将保存后的shp再次可视化
结果相同

论文#
mesh-gpt论文
Transformer的翻译模型和补全模型
对于补全模型
微信(GPT和Bert的预训练)
mesh—gpt、cad(generate)
编码器:他是谁
Transformer:整个场景表达了怎样的语义,(他是否满足这个语义,他在这个语义场景中扮演什么)
long long ago, .....
Next
Transformer-GPT原理
Mesh-GPT demo
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步