[{"content":"","date":null,"permalink":"https://gentleostrich.github.io/","section":"","summary":"","title":""},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/posts/","section":"","summary":"","title":""},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/tags/buaa/","section":"Tags","summary":"","title":"BUAA"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/categories/","section":"Categories","summary":"","title":"Categories"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/tags/","section":"Tags","summary":"","title":"Tags"},{"content":" 考试已经过去一周了，根据依稀的记忆写下这篇考试回忆，希望能对后来的同学有所帮助。\n本次机器学习期末考试包含大量往年题目，如决策树、反向传播推导、按照最小错误率和最小风险求后验等等。\n临近考试不要慌张，多看往年经验分享博客、掌握老师说过的的必考知识点、补齐课件中短板、自信应对考试就可以啦。\n以下内容为笔者回忆版，不保证准确性，请各位读者有选择性地参考。\nT1 贝叶斯决策 #给出先验概率和类条件概率，决策损失函数 \\(\\lambda\\)（其实就是选错的风险值）\n使用最小错误率进行决策 使用最小风险进行决策 T2 K-means # 使用数学语言描述 K-means 的流程 执行一遍 K-means 流程（给定 4 个二维点的坐标，初始化了 2 个二维中心点，要求迭代执行 2 次），并简述 EM 算法的 E-step 和 M-step 分别对应 K-means 中的哪个流程 K-means 的缺陷以及解决办法（K-means++） T3 PCA # 简述最大方差、最小均方误差的主要思想 PCA 的一般求解过程（求协方差矩阵、最大特征值对应的特征向量等等） 与 LDA 的关系与区别 T4 SVM # 从几何解析的角度描述参数 w 和 b 的意义 说明惩罚系数和松弛变量的作用 T5 关联规则学习 # 简述先验算法的基本思想（支持度之类的） 简述关联规则学习的应用场景（社交网络、货品分类） T6 半监督学习 # 简述聚类假设和流形假设\n简述一种半监督学习的方法\nT7 集成学习 # 叙述集成学习的思想\n简述 boosting 和 bagging 的执行流程\nT8 决策树 #判断学生是否会加入算法竞赛集训队，4 个属性：GPA（高、中、低）、感兴趣程度（高、一般、低）、时间（充足、一般、紧张）、编程能力（高、中、低）。虽然题目给出了计算所需的 log 值，但笔者还是建议使用计算器。\n按照 ID3 流程生成决策树（4 个属性看似十分复杂，实际上只需要两轮迭代） 给定一个同学的属性，判断他是否会加入（第一题没做出来的话也可以通过观察法判断） 简述预剪枝和后剪枝的方法和优缺点 T9 反向传播 #给定带有一个隐藏层的前馈全连接神经网络，隐藏层和输出层都有激活函数\n推导第一层和第二层参数 w 如何更新 动量 SGD 和 Adam 是如何解决陷入局部极值点或震荡问题 简述为什么会出现梯度消失，如何缓解这个现象 T10 强化学习 #简述强化学习在大语言模型或机器人领域的应用\n往年博客 # https://blog.csdn.net/weixin_66992679/article/details/145398059 https://blog.csdn.net/weixin_52843454/article/details/135317356 https://theuho.site/2025/08/11/ML-final/ https://theuho.site/2025/08/11/ML-review/ https://blog.csdn.net/m0_59182181/article/details/145010304 https://suzumiyaakizuki.github.io/2024/12/21/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%9C%9F%E6%9C%AB%E8%80%83%E8%AF%95%E4%BE%8B%E9%A2%98%E6%B1%87%E6%80%BB/ ","date":"2026-01-19","permalink":"https://gentleostrich.github.io/posts/%E5%8C%97%E8%88%AA-buaa-2025-%E7%A7%8B%E7%A0%94%E7%A9%B6%E7%94%9F%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%9C%9F%E6%9C%AB%E8%80%83%E8%AF%95%E5%9B%9E%E5%BF%86%E7%89%88/","section":"","summary":"\u003cp\u003e\n\n考试已经过去一周了，根据依稀的记忆写下这篇考试回忆，希望能对后来的同学有所帮助。\u003c/p\u003e\n\u003cp\u003e本次机器学习期末考试包含大量往年题目，如决策树、反向传播推导、按照最小错误率和最小风险求后验等等。\u003c/p\u003e\n\u003cp\u003e临近考试不要慌张，多看往年经验分享博客、掌握老师说过的的必考知识点、补齐课件中短板、自信应对考试就可以啦。\u003c/p\u003e\n\u003cp\u003e以下内容为笔者回忆版，不保证准确性，请各位读者有选择性地参考。\u003c/p\u003e\n\u003ch2 id=\"t1-贝叶斯决策\" class=\"relative group\"\u003eT1 贝叶斯决策 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t1-%e8%b4%9d%e5%8f%b6%e6%96%af%e5%86%b3%e7%ad%96\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003e给出先验概率和类条件概率，决策损失函数 \\(\\lambda\\)（其实就是选错的风险值）\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003e使用最小错误率进行决策\u003c/li\u003e\n\u003cli\u003e使用最小风险进行决策\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"t2-k-means\" class=\"relative group\"\u003eT2 K-means \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t2-k-means\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003col\u003e\n\u003cli\u003e使用数学语言描述 K-means 的流程\u003c/li\u003e\n\u003cli\u003e执行一遍 K-means 流程（给定 4 个二维点的坐标，初始化了 2 个二维中心点，要求迭代执行 2 次），并简述 EM 算法的 E-step 和 M-step 分别对应 K-means 中的哪个流程\u003c/li\u003e\n\u003cli\u003eK-means 的缺陷以及解决办法（K-means++）\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"t3-pca\" class=\"relative group\"\u003eT3 PCA \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t3-pca\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003col\u003e\n\u003cli\u003e简述最大方差、最小均方误差的主要思想\u003c/li\u003e\n\u003cli\u003ePCA 的一般求解过程（求协方差矩阵、最大特征值对应的特征向量等等）\u003c/li\u003e\n\u003cli\u003e与 LDA 的关系与区别\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"t4-svm\" class=\"relative group\"\u003eT4 SVM \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t4-svm\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003col\u003e\n\u003cli\u003e从几何解析的角度描述参数 w 和 b 的意义\u003c/li\u003e\n\u003cli\u003e说明惩罚系数和松弛变量的作用\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"t5-关联规则学习\" class=\"relative group\"\u003eT5 关联规则学习 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t5-%e5%85%b3%e8%81%94%e8%a7%84%e5%88%99%e5%ad%a6%e4%b9%a0\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003col\u003e\n\u003cli\u003e简述先验算法的基本思想（支持度之类的）\u003c/li\u003e\n\u003cli\u003e简述关联规则学习的应用场景（社交网络、货品分类）\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"t6-半监督学习\" class=\"relative group\"\u003eT6 半监督学习 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#t6-%e5%8d%8a%e7%9b%91%e7%9d%a3%e5%ad%a6%e4%b9%a0\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003col\u003e\n\u003cli\u003e\n\u003cp\u003e简述聚类假设和流形假设\u003c/p\u003e","title":"北航 BUAA 2025 秋研究生机器学习期末考试回忆版"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/","section":"Categories","summary":"","title":"机器学习"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/tags/sam-3d/","section":"Tags","summary":"","title":"SAM 3D"},{"content":"安装 #参考官方安装教程在服务器上配置环境，服务器全程使用 clash 代理，使用 conda 安装\n环境配置 ## 克隆项目仓库 git clone https://github.com/facebookresearch/sam-3d-objects.git cd sam-3d-objects # 创建 conda 环境 conda env create -f environments/default.yml conda activate sam3d-objects # 设置 pytorch 等安装的 URL export PIP_EXTRA_INDEX_URL=\u0026#34;https://pypi.ngc.nvidia.com https://download.pytorch.org/whl/cu121\u0026#34; # 安装 sam 3d 核心依赖 pip install -e \u0026#39;.[dev]\u0026#39; pip install -e \u0026#39;.[p3d]\u0026#39; # pytorch3d dependency on pytorch is broken, this 2-step approach solves it # 安装 sam 3d 推理 export PIP_FIND_LINKS=\u0026#34;https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.5.1_cu121.html\u0026#34; pip install -e \u0026#39;.[inference]\u0026#39; 下载官方权重文件 #首先需要在 huggingface 上申请许可，笔者使用新邮箱创建了一个新的 huggingface 账户，在申请许可需要填入的个人信息中填写美国地址、学校等等，否则容易被拒。获得许可后，执行：\npip install \u0026#39;huggingface-hub[cli]\u0026lt;1.0\u0026#39; TAG=hf hf download \\ --repo-type model \\ --local-dir checkpoints/${TAG}-download \\ --max-workers 1 \\ facebook/sam-3d-objects mv checkpoints/${TAG}-download/checkpoints checkpoints/${TAG} rm -rf checkpoints/${TAG}-download hf download 执行后，会要求填入 huggingface 账号的 token，点击右上角个人头像，进入 access tokens 中新建 token，全部打勾提交，即可获得账号 token。复制 token，在服务器命令行中鼠标右键粘贴回车后，就可以开始下载模型文件了。成功下载后，checkpoints 文件保存在 sam-3d-objects/checkpoints/hf 目录。\n测试 demo #执行 pythonn demo.py 成功执行后会生成 splat.ply 物体三维重建的高斯点云结果\nmesh #demo 中输出的三维是点云，保存在输出的 gs 属性中。下述是issue 31中作者给出的模型输出中的各个属性\nThose are all the outputs from our model.\n\u0026ldquo;scale\u0026rdquo;, \u0026ldquo;translation\u0026rdquo;, \u0026ldquo;rotation\u0026rdquo; are informations about object pose. \u0026ldquo;pointmap\u0026rdquo; is the MoGe pointmap used internally by the layout model. \u0026ldquo;gs\u0026rdquo;, \u0026ldquo;glb\u0026rdquo; are the 3D object (gaussian splatting and Trimesh mesh). To get the object dimensions in the scene, you would need to move the object in the scene reference frame and calculate the 3D bbox of the object using the gaussians xyz coordinates. You can have a look at the make_scene function to do the first step.\n可见，glb 属性是重建的 mesh，导出代码 如下：\noutput = inference(image, mask, seed=42) mesh = output[\u0026#34;glb\u0026#34;] mesh.export(\u0026#34;modle.glb\u0026#34;) texture #在 notebook/inference.py 文件中的 Inference 类可以更改模型运行的相关设置，如 with_mesh_postprocess with_texture_postprocess 等（等价于在 sam3d_objects/pipeline/inference_pipeline.py 中 Class InferencePipeline 的 def postprocess_slat_output 中做更详细的修改，参考）。其中，with_texture_postprocess 可以产生 texture。\n使用 with_texture_postprocess = True 时产生了报错 TypeError: GaussianRasterizationSettings.__new__() got an unexpected keyword argument 'kernel_size'，安装相应的 python 包 解决了报错\n设置 with_mesh_postprocess 和 with_texture_postprocess 均为 True，就可以生成带有 texture 的 mesh 了。（导入 Blender 后要把左上角的 Object Mode 改为 Texture Paint）\n多视角 sam-3d-object #项目地址\n克隆该项目后发现，sam3d_objects 目录并非原版，在 MV-SAM3D/sam3d_objects/utils 实现了 attetion 机制等进行多视角融合。所以，一开始将原版 sam3d_objects 拷贝到这里是不对的，而是应该根据执行 demo 产生的报错，向该目录中补齐缺少的部分（如 checkpoints 等等） 。\n三维重建自己的图片 #单视角 #sam-3d-object 的输入是原始图片和经过 mask 的目标物体图片，所以第一步需要利用某些方法对原图像目标物体做 mask，之后按照 sam-3d-object 的 demo 过程执行即可。示例代码 如下：\n# 1. Load SAM3 and segment the image print(f\u0026#34;Loading SAM3 Model and segmenting: \u0026#39;{prompt}\u0026#39;...\u0026#34;) model = Sam3Model.from_pretrained(\u0026#34;facebook/sam3\u0026#34;).to(device) processor = Sam3Processor.from_pretrained(\u0026#34;facebook/sam3\u0026#34;) image_pil = Image.open(image_path).convert(\u0026#34;RGB\u0026#34;) inputs = processor(images=image_pil, text=prompt, return_tensors=\u0026#34;pt\u0026#34;).to(device) with torch.no_grad(): outputs = model(**inputs) results = processor.post_process_instance_segmentation( outputs, threshold=0.5, mask_threshold=0.5, target_sizes=inputs.get(\u0026#34;original_sizes\u0026#34;).tolist() )[0] if len(results[\u0026#39;masks\u0026#39;]) == 0: print(f\u0026#34;No objects matching \u0026#39;{prompt}\u0026#39; were found.\u0026#34;) return mask_input = results[\u0026#39;masks\u0026#39;][0].cpu().numpy() if mask_input.ndim == 3: mask_input = np.squeeze(mask_input) # Prepare image for SAM3D image_np = np.array(image_pil).astype(np.uint8) # 2. Run SAM3D Inference print(\u0026#34;Initializing SAM3D reconstruction...\u0026#34;) config_path = \u0026#34;checkpoints/hf/pipeline.yaml\u0026#34; inference = Inference(config_path, compile=False) print(\u0026#34;Generating 3D object...\u0026#34;) output = inference(image_np, mask_input, seed=42) # 3. Save output output[\u0026#34;gs\u0026#34;].save_ply(output_path) print(f\u0026#34;Success! Reconstruction saved to: {output_path}\u0026#34;) （SAM3使用SAM3DObjests的环境就可以运行起来）\n多视角 # 多视角图片要经过 SAM3 批处理 生成对应的mask\n使用方法：参考，将该项目中的 sam3d_objects 替换原目录（其中 inference_pipeline.py）实现了多视角重建功能\n具体代码：\n\u0026#34;\u0026#34;\u0026#34; 使用 SAM3 和 SAM-3D-Objects 从单张单物品图像和文本提示进行 3D 重建。 需要使用代理。 \u0026#34;\u0026#34;\u0026#34; import argparse import os from pathlib import Path import torch from PIL import Image import numpy as np device = \u0026#34;cuda\u0026#34; if torch.cuda.is_available() else \u0026#34;cpu\u0026#34; def get_images_and_masks(images_path, prompt): \u0026#34;\u0026#34;\u0026#34; 使用 SAM3 批处理，根据文本提示生成掩码， :param images_path: 图像路径 :param prompt: 文本提示 \u0026#34;\u0026#34;\u0026#34; from transformers import Sam3Processor, Sam3Model # 可不可以不用 tansformers print(f\u0026#34;Loading images ...\u0026#34;) images = load_images(images_path) # 1. Load SAM3 and segment the image print(f\u0026#34;Loading SAM3 Model and segmenting: \u0026#39;{prompt}\u0026#39;...\u0026#34;) model = Sam3Model.from_pretrained(\u0026#34;facebook/sam3\u0026#34;).to(device) processor = Sam3Processor.from_pretrained(\u0026#34;facebook/sam3\u0026#34;) text_prompts = [prompt] * len(images) inputs = processor(images=images, text=text_prompts, return_tensors=\u0026#34;pt\u0026#34;).to(device) with torch.no_grad(): outputs = model(**inputs) results = processor.post_process_instance_segmentation( outputs, threshold=0.5, mask_threshold=0.5, target_sizes=inputs.get(\u0026#34;original_sizes\u0026#34;).tolist() ) masks = [] for i, result in enumerate(results): result = result[\u0026#34;masks\u0026#34;] if len(result) == 0: print(f\u0026#34;No objects matching {prompt} were found in image {i}.\u0026#34;) exit(1) mask = result[0].cpu().numpy() if mask.ndim == 3: mask = np.squeeze(mask) masks.append(mask) return images, masks def recon(images, masks, output_path): \u0026#34;\u0026#34;\u0026#34; 使用 SAM-3D-Objects 进行 3D 重建。 :param images: 使用 PIL.Image 打开的图片列表 :param masks: 掩码列表 :param output_path: 输出路径 \u0026#34;\u0026#34;\u0026#34; from inference import Inference config_path = \u0026#34;checkpoints/hf/pipeline.yaml\u0026#34; inference = Inference(config_path, compile=False) result = inference._pipeline.run_multi_view( view_images=images, view_masks=masks, seed=42, mode=\u0026#34;multidiffusion\u0026#34;, stage1_inference_steps=50, stage2_inference_steps=25, decode_formats=\u0026#34;gaussian,mesh\u0026#34;, with_mesh_postprocess=False, with_texture_baking=False, use_vertex_color=True, ) print(f\u0026#34;\\n{\u0026#39;=\u0026#39;*60}\u0026#34;) print(f\u0026#34;Inference completed!\u0026#34;) print(f\u0026#34;Generated coordinates: {result[\u0026#39;coords\u0026#39;].shape[0] if \u0026#39;coords\u0026#39; in result else \u0026#39;N/A\u0026#39;}\u0026#34;) print(f\u0026#34;{\u0026#39;=\u0026#39;*60}\u0026#34;) saved_files = [] if \u0026#39;glb\u0026#39; in result and result[\u0026#39;glb\u0026#39;] is not None: result[\u0026#39;glb\u0026#39;].export(str(output_path / \u0026#34;result.glb\u0026#34;)) saved_files.append(\u0026#34;result.glb\u0026#34;) print(f\u0026#34;✓ GLB file saved to: {output_path / \u0026#39;result.glb\u0026#39;}\u0026#34;) if \u0026#39;gs\u0026#39; in result: result[\u0026#39;gs\u0026#39;].save_ply(str(output_path / \u0026#34;result.ply\u0026#34;)) saved_files.append(\u0026#34;result.ply\u0026#34;) print(f\u0026#34;✓ Gaussian Splatting (PLY) saved to: {output_path / \u0026#39;result.ply\u0026#39;}\u0026#34;) elif \u0026#39;gaussian\u0026#39; in result: if isinstance(result[\u0026#39;gaussian\u0026#39;], list) and len(result[\u0026#39;gaussian\u0026#39;]) \u0026gt; 0: result[\u0026#39;gaussian\u0026#39;][0].save_ply(str(output_path / \u0026#34;result.ply\u0026#34;)) saved_files.append(\u0026#34;result.ply\u0026#34;) print(f\u0026#34;✓ Gaussian Splatting (PLY) saved to: {output_path / \u0026#39;result.ply\u0026#39;}\u0026#34;) if \u0026#39;mesh\u0026#39; in result: print(f\u0026#34;✓ Mesh information generated (included in GLB)\u0026#34;) print(f\u0026#34;\\n{\u0026#39;=\u0026#39;*60}\u0026#34;) print(f\u0026#34;All output files saved to: {output_path}\u0026#34;) print(f\u0026#34;Saved files: {\u0026#39;, \u0026#39;.join(saved_files)}\u0026#34;) print(f\u0026#34;{\u0026#39;=\u0026#39;*60}\u0026#34;) def load_images(images_path): \u0026#34;\u0026#34;\u0026#34; 加载图像。 :param images_path: 图像路径 :return: 使用 PIL.Image 打开的图片 \u0026#34;\u0026#34;\u0026#34; images = [] files = sorted(images_path.glob(\u0026#34;*.jpg\u0026#34;)) if len(files) == 0: raise FileNotFoundError(f\u0026#34;No images found in path: {images_path}\u0026#34;) for file in files: image = Image.open(file).convert(\u0026#34;RGB\u0026#34;) images.append(image) return images def main(): parser = argparse.ArgumentParser( description=\u0026#34;Run SAM3D reconstruction from a single image and text prompt.\u0026#34; ) parser.add_argument( \u0026#34;--images_path\u0026#34;, type=str, default=\u0026#34;images/bottle\u0026#34;, help=\u0026#34;Path to the input image directory.\u0026#34;, ) parser.add_argument( \u0026#34;--prompt\u0026#34;, type=str, default=\u0026#34;a bottle\u0026#34;, help=\u0026#34;Text prompt to segment the object of interest.\u0026#34;, ) args = parser.parse_args() images_path = Path(args.images_path) if not images_path.exists(): raise FileNotFoundError(f\u0026#34;Input path does not exist: {images_path}\u0026#34;) if not images_path.is_dir(): raise ValueError(\u0026#34;For multiview reconstruction, images_path should be a directory.\u0026#34;) # images = load_images(images_path) prompt = args.prompt output_path = Path(f\u0026#34;outputs/{images_path.stem}/\u0026#34;) os.makedirs(output_path, exist_ok=True) images, masks = get_images_and_masks(images_path, prompt) recon(images, masks, output_path) if __name__ == \u0026#34;__main__\u0026#34;: main() ","date":"2026-01-15","permalink":"https://gentleostrich.github.io/posts/sam-3d-object-%E6%95%99%E7%A8%8B/","section":"","summary":"\u003ch2 id=\"安装\" class=\"relative group\"\u003e安装 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#%e5%ae%89%e8%a3%85\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003e参考\u003ca href=\"https://github.com/facebookresearch/sam-3d-objects/blob/main/doc/setup.md\" target=\"_blank\" rel=\"noreferrer\"\u003e官方安装教程\u003c/a\u003e在服务器上配置环境，服务器全程使用 clash 代理，使用 conda 安装\u003c/p\u003e\n\u003ch3 id=\"环境配置\" class=\"relative group\"\u003e环境配置 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h3\u003e\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-shell\" data-lang=\"shell\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# 克隆项目仓库\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003egit clone https://github.com/facebookresearch/sam-3d-objects.git\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"nb\"\u003ecd\u003c/span\u003e sam-3d-objects\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# 创建 conda 环境\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003econda env create -f environments/default.yml\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003econda activate sam3d-objects\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# 设置 pytorch 等安装的 URL\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"nb\"\u003eexport\u003c/span\u003e \u003cspan class=\"nv\"\u003ePIP_EXTRA_INDEX_URL\u003c/span\u003e\u003cspan class=\"o\"\u003e=\u003c/span\u003e\u003cspan class=\"s2\"\u003e\u0026#34;https://pypi.ngc.nvidia.com https://download.pytorch.org/whl/cu121\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# 安装 sam 3d 核心依赖\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003epip install -e \u003cspan class=\"s1\"\u003e\u0026#39;.[dev]\u0026#39;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003epip install -e \u003cspan class=\"s1\"\u003e\u0026#39;.[p3d]\u0026#39;\u003c/span\u003e \u003cspan class=\"c1\"\u003e# pytorch3d dependency on pytorch is broken, this 2-step approach solves it\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# 安装 sam 3d 推理\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"nb\"\u003eexport\u003c/span\u003e \u003cspan class=\"nv\"\u003ePIP_FIND_LINKS\u003c/span\u003e\u003cspan class=\"o\"\u003e=\u003c/span\u003e\u003cspan class=\"s2\"\u003e\u0026#34;https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.5.1_cu121.html\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003epip install -e \u003cspan class=\"s1\"\u003e\u0026#39;.[inference]\u0026#39;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"下载官方权重文件\" class=\"relative group\"\u003e下载官方权重文件 \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#%e4%b8%8b%e8%bd%bd%e5%ae%98%e6%96%b9%e6%9d%83%e9%87%8d%e6%96%87%e4%bb%b6\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h3\u003e\u003cp\u003e首先需要在 huggingface 上申请许可，笔者使用新邮箱创建了一个新的 huggingface 账户，在申请许可需要填入的个人信息中填写美国地址、学校等等，否则容易被拒。获得许可后，执行：\u003c/p\u003e","title":"SAM 3D Objects 教程"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/categories/%E4%B8%89%E7%BB%B4%E9%87%8D%E5%BB%BA/","section":"Categories","summary":"","title":"三维重建"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/tags/hugo/","section":"Tags","summary":"","title":"Hugo"},{"content":"官方教程不允许使用 CMD、Windows PowerShell 执行各个命令，建议使用 PowerShell 执行命令。Anaconda Powershell Prompt 应该是基于 PowerShell 开发的，因此，本文的命令均在 Anaconda Powershell Prompt 中执行。\n安装 Hugo #安装 Hugo 前需要安装 Git、Go、Dart Sass。\n安装 Git\n无论是克隆 Hugo 的 GitHub 仓库，还是基于 Github Page 发布网站，都需要使用 Git。\n安装 Go\nHugo 是基于 Go 语言开发，Go 作为一种高效的编程语言，使得 Hugo 在速度上远超 Hexo 等静态网站搭建技术。\n安装 Dart Sass\nDart Sass 是 Hugo 开发的网页渲染插件，可以通过 Scoop 和 Chocolatey 两个 Windows 安装器安装，这里选择使用 Scoop 安装。\n安装 Scoop\n首先 cd 到 C:\\ 路径，在 C:\\ 路径下执行下述命令。\nSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression 按照上述官方命令安装时出现了 PowerShell 禁止运行脚本的报错，使用 以下命令 替代上面的第一条命令解决该问题。\nSet-ExecutionPolicy RemoteSigned -Scope Process Set-ExecutionPolicy RemoteSigned -Scope CurrentUser Set-ExecutionPolicy RemoteSigned -Scope LocalMachine 安装 Scoop 后，可以执行下述命令安装 Dart Sass。\nscoop install sass 安装 Git、Go、Dart Sass 后\n在 Hugo GitHub 发布页 下载并解压 hugo_0.154.5_windows-amd64.zip 。 将解压得到的文件 hugo.exe 移动到安装路径，这里选择的安装路径是 D:\\Program Files\\hugo，并将该路径添加到系统路径变量中。 此时，重新打开 PowerShell 并执行 hugo version，若输出 Hugo 的版本号等信息，则表明 Hugo 安装成功。\n网站创建 #成功安装 Hugo 后，就可以创建第一个网站了。\nhugo new site quickstart cd quickstart git init git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke echo \u0026#34;theme = \u0026#39;ananke\u0026#39;\u0026#34; \u0026gt;\u0026gt; hugo.toml hugo server 报错 1：\nERROR command error: failed to load config: \u0026#34;D:\\Program Files\\hugo\\quickstart\\hugo.toml:4:2\u0026#34;: unmarshal failed: toml: expected character = 直接将 echo \u0026quot;theme = 'ananke'\u0026quot; \u0026gt;\u0026gt; hugo.toml 复制到 PowerShell 中执行会出现格式错误，修改 hugo.toml\n报错 2：\nERROR error building site: render: [en v1.0.0 guest] failed to render pages: render of \u0026#34;/tags\u0026#34; failed: \u0026#34;D:\\Program Files\\hugo\\quickstart\\themes\\ananke\\layouts\\baseof.html:26:15\u0026#34;: execute of template failed: template: taxonomy.html:26:15: executing \u0026#34;taxonomy.html\u0026#34; at \u0026lt;partials.Include\u0026gt;: error calling Include: \u0026#34;D:\\Program Files\\hugo\\quickstart\\themes\\ananke\\layouts\\_partials\\site-style.html:2:32\u0026#34;: execute of template failed: template: _partials/site-style.html:2:32: executing \u0026#34;_partials/site-style.html\u0026#34; at \u0026lt;.RelPermalink\u0026gt;: error calling RelPermalink: TOCSS: failed to transform \u0026#34;/ananke/css/main.css\u0026#34; (text/css). Check your Hugo installation; you need the extended version to build SCSS/SASS with transpiler set to \u0026#39;libsass\u0026#39;.: this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information 这是因为通过 hugo_0.154.5_windows-amd64.zip 安装的不是 extended version，不能对 anake 主题进行渲染。执行命令 scoop install hugo-extended 直接从 scoop 中安装 hugo-extended 并删除系统路径中的 hugo 路径即可。\n网站配置 #通过目录下的 hugo.toml 配置网站，其中的 baseURL 设置为生产网站。\nbaseURL = \u0026#39;https://example.org/\u0026#39; languageCode = \u0026#39;en-us\u0026#39; title = \u0026#39;My New Hugo Site\u0026#39; theme = \u0026#39;ananke\u0026#39; 内容添加 #向网站中添加一个新文章：\nhugo new content content/posts/my-first-post.md 在 content/posts 目录下出现了 my-first-post.md 文件，下述是该文件中的内容。其中 draft=true 表示这个文章不会被发表到网站上。\n+++ title = \u0026#39;My First Post\u0026#39; date = 2024-01-14T07:07:07+01:00 draft = true +++ 通过下述命令查看含有 draft 文章的网站，当决定发表该文章后，将 draft 改为 false。\nhugo server --buildDrafts hugo server -D 网站发布 #网站发布指的是 Hugo 在 public 目录下创建静态网站所需的全部文件（包括 HTML 文件、CSS 文件、Javascript 文件、图片得等等），命令如下：\nhugo 网站部署 #基于 GitHub Page 部署网站。\n新建项目，项目名称为：\u0026lt;username\u0026gt;.github.io。这意味着这个项目是一个网站，每次 push 后都会进行 action 操作进行网站部署。\n将本地 Hugo 仓库与 GitHub 项目仓库进行 remote 关联，代码如下：\ngit remote add origin https://github.com/GentleOstrich/gentleostrich.github.io.git git branch -M main git push -u origin main 报错：\ngit push -u origin mainerror: src refspec main does not match any error: failed to push some refs to \u0026#39;https://github.com/GentleOstrich/gentleostrich.github.io.git\u0026#39; 原因是最开始本地项目从未 commit 过，所以没有不存在分支 main。执行下述命令即可解决：\ngit commit -m \u0026#34;Initial commit\u0026#34; git push -u origin main 设置图片缓存位置\n在 hugo.toml 文件中添加下述内容：\n[caches] [caches.images] dir = \u0026#39;:cacheDir/images\u0026#39; 设置 action 文件\naction 文件的作用是指导 GitHub 如何部署网站的，首先创建相关 hugo.yaml 文件：\nmkdir -p .github/workflows touch .github/workflows/hugo.yaml 接下来在 hugo.yaml 文件中加入下述内容：\nname: Build and deploy on: push: branches: - main workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: false defaults: run: shell: bash jobs: build: runs-on: ubuntu-latest env: DART_SASS_VERSION: 1.97.2 GO_VERSION: 1.25.5 HUGO_VERSION: 0.154.4 NODE_VERSION: 24.12.0 TZ: Europe/Oslo steps: - name: Checkout uses: actions/checkout@v6 with: submodules: recursive fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ env.GO_VERSION }} cache: false - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: ${{ env.NODE_VERSION }} - name: Setup Pages id: pages uses: actions/configure-pages@v5 - name: Create directory for user-specific executable files run: | mkdir -p \u0026#34;${HOME}/.local\u0026#34; - name: Install Dart Sass run: | curl -sLJO \u0026#34;https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz\u0026#34; tar -C \u0026#34;${HOME}/.local\u0026#34; -xf \u0026#34;dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz\u0026#34; rm \u0026#34;dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz\u0026#34; echo \u0026#34;${HOME}/.local/dart-sass\u0026#34; \u0026gt;\u0026gt; \u0026#34;${GITHUB_PATH}\u0026#34; - name: Install Hugo run: | curl -sLJO \u0026#34;https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz\u0026#34; mkdir \u0026#34;${HOME}/.local/hugo\u0026#34; tar -C \u0026#34;${HOME}/.local/hugo\u0026#34; -xf \u0026#34;hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz\u0026#34; rm \u0026#34;hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz\u0026#34; echo \u0026#34;${HOME}/.local/hugo\u0026#34; \u0026gt;\u0026gt; \u0026#34;${GITHUB_PATH}\u0026#34; - name: Verify installations run: | echo \u0026#34;Dart Sass: $(sass --version)\u0026#34; echo \u0026#34;Go: $(go version)\u0026#34; echo \u0026#34;Hugo: $(hugo version)\u0026#34; echo \u0026#34;Node.js: $(node --version)\u0026#34; - name: Install Node.js dependencies run: | [[ -f package-lock.json || -f npm-shrinkwrap.json ]] \u0026amp;\u0026amp; npm ci || true - name: Configure Git run: | git config core.quotepath false - name: Cache restore id: cache-restore uses: actions/cache/restore@v5 with: path: ${{ runner.temp }}/hugo_cache key: hugo-${{ github.run_id }} restore-keys: hugo- - name: Build the site run: | hugo \\ --gc \\ --minify \\ --baseURL \u0026#34;${{ steps.pages.outputs.base_url }}/\u0026#34; \\ --cacheDir \u0026#34;${{ runner.temp }}/hugo_cache\u0026#34; - name: Cache save id: cache-save uses: actions/cache/save@v5 with: path: ${{ runner.temp }}/hugo_cache key: ${{ steps.cache-restore.outputs.cache-primary-key }} - name: Upload artifact uses: actions/upload-pages-artifact@v4 with: path: ./public deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 至此，等待 GitHub 项目主页中 Action 显示绿色对勾后，就可以通过网址 \u0026lt;username\u0026gt;.github.io 访问网站啦（可能显示绿色对勾后立刻访问网站会出现 403 错误，只需要再等待一会儿就可以正常访问了）\nshortcode #可用于内嵌视频、图片等元素，分为 embedded custom inline 三类。\n插入一个 Youtube 视频（是一个 embedded）： `\n插入日期（是一个 inline）：今天是 2026年1月22日。\n插入二维码：\ncustom 类 #This is 2026, and look at how far we\u0026rsquo;ve come.\n2026-01-22 更新 \u003c?xml version=\"1.0\" standalone=\"no\"?\u003e \u003c!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"\u003e \u003c?xml version=\"1.0\" standalone=\"no\"?\u003e \u003c!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"\u003e this is not good 如何在文章中添加图片？传到ghpage上时，文章目录下不能有多余的图片？无法用shortcodes引用！！\n\\(f(a,b,c) = (a^2+b^2+c^2)^3\\) 注意是两个斜杠\n\\(\\varphi = \\dfrac{1+\\sqrt5}{2}= 1.6180339887…\\)\n$$ \\varphi = 1+\\frac{1} {1+\\frac{1} {1+\\frac{1} {1+\\cdots} } } $$\n名人名言放在开头会显得很有逼格 —— 佚名 展示自我！\nGentleOstrich Easy come , easy go. 关于 shortcode 还有许多东西，还没学习 ……\nPartials # TODO ","date":"2026-01-14","permalink":"https://gentleostrich.github.io/posts/windows-11-%E5%88%9B%E5%BB%BA-hugo-%E7%BD%91%E7%AB%99/","section":"","summary":"\u003cp\u003e官方教程不允许使用 CMD、Windows PowerShell 执行各个命令，建议使用 PowerShell 执行命令。Anaconda Powershell Prompt 应该是基于 PowerShell 开发的，因此，本文的命令均在 Anaconda Powershell Prompt 中执行。\u003c/p\u003e\n\u003ch2 id=\"安装-hugo\" class=\"relative group\"\u003e安装 Hugo \u003cspan class=\"absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100\"\u003e\u003ca class=\"group-hover:text-primary-300 dark:group-hover:text-neutral-700\" style=\"text-decoration-line: none !important;\" href=\"#%e5%ae%89%e8%a3%85-hugo\" aria-label=\"锚点\"\u003e#\u003c/a\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003e安装 Hugo 前需要安装 Git、Go、Dart Sass。\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e安装 \u003ca href=\"https://git-scm.com/book/en/v2/Getting-Started-Installing-Git\" target=\"_blank\" rel=\"noreferrer\"\u003eGit\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003e无论是克隆 Hugo 的 GitHub 仓库，还是基于 Github Page 发布网站，都需要使用 Git。\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e安装 \u003ca href=\"https://go.dev/doc/install\" target=\"_blank\" rel=\"noreferrer\"\u003eGo\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eHugo 是基于 Go 语言开发，Go 作为一种高效的编程语言，使得 Hugo 在速度上远超 Hexo 等静态网站搭建技术。\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e安装 \u003ca href=\"https://gohugo.io/functions/css/sass/#dart-sass\" target=\"_blank\" rel=\"noreferrer\"\u003eDart Sass\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eDart Sass 是 Hugo 开发的网页渲染插件，可以通过 Scoop 和 Chocolatey 两个 Windows 安装器安装，这里选择使用 Scoop 安装。\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e安装 \u003ca href=\"https://scoop.sh/#/\" target=\"_blank\" rel=\"noreferrer\"\u003eScoop\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003e首先 cd 到 C:\\ 路径，在 C:\\ 路径下执行下述命令。\u003c/p\u003e","title":"Windows 11 创建 Hugo 网站"},{"content":"","date":null,"permalink":"https://gentleostrich.github.io/categories/%E7%BD%91%E7%BB%9C/","section":"Categories","summary":"","title":"网络"},{"content":"","date":"0001-01-01","permalink":"https://gentleostrich.github.io/about/","section":"","summary":"","title":""}]