[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-rafellerc--Pytorch-SiamFC":3,"tool-rafellerc--Pytorch-SiamFC":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",160411,2,"2026-04-18T23:33:24",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":76,"owner_website":76,"owner_url":77,"languages":78,"stars":87,"forks":88,"last_commit_at":89,"license":90,"difficulty_score":10,"env_os":91,"env_gpu":92,"env_ram":93,"env_deps":94,"category_tags":107,"github_topics":108,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":114,"updated_at":115,"faqs":116,"releases":150},9464,"rafellerc\u002FPytorch-SiamFC","Pytorch-SiamFC","Pytorch implementation of \"Fully-Convolutional Siamese Networks for Object Tracking\"","Pytorch-SiamFC 是经典目标跟踪算法“全卷积孪生网络（Siamese FC）”的 PyTorch 版本复现。它旨在解决视频序列中如何快速、准确地锁定并跟随特定物体的问题。其核心原理是通过一个共享权重的双分支神经网络，分别提取目标模板和搜索区域的特征，再利用互相关运算生成响应图，图中峰值位置即为目标的新坐标。\n\n相较于原始 MATLAB 实现，该项目不仅让算法在深度学习主流框架中得以运行，还针对训练过程进行了优化。它采用每轮动态采样图像对的策略，有效降低了模型过拟合的风险，提升了泛化能力。尽管在部分精度指标上与原版存在细微差距，但其代码结构清晰，完整涵盖了模型训练、实时跟踪及可视化演示三大模块，并提供了预训练模型供直接调用。\n\n这款工具非常适合计算机视觉领域的研究人员、算法工程师及高校学生使用。对于希望深入理解孪生网络跟踪机制、复现经典论文结果，或需要基于此架构进行二次开发以适配新场景的开发者而言，Pytorch-SiamFC 是一个极具参考价值的开源基准项目。","# SiameseFC PyTorch implementation\n\n## Introduction\n\nThis project is the Pytorch implementation of the object tracker presented in \n[Fully-Convolutional Siamese Networks for Object Tracking](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1606.09549.pdf),\nalso available at [their project page](https:\u002F\u002Fwww.robots.ox.ac.uk\u002F~luca\u002Fsiamese-fc.html).\nThe original version was written in matlab with the MatConvNet framework, available\n[here](https:\u002F\u002Fgithub.com\u002Fbertinetto\u002Fsiamese-fc) (trainining and tracking), but this\npython version is adapted from the TensorFlow portability (tracking only),\navailable [here](https:\u002F\u002Fgithub.com\u002Ftorrvision\u002Fsiamfc-tf).\n\n## Organization\n\nThe project is divided into three major parts: [**Training**](#training), [**Tracking**](#tracking) and a [**Visualization Application**](#visualization-application).\n\n## Training\n\nThe main focus of this work, the **Training** part deals with the training of the Siamese Network in order to learn a similarity metric between patches, as\ndescribed in the paper.\n\n\u003Ccenter>\n    \u003Cfigure>    \n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_e7742ce1131d.png\" height=\"50%\" width=\"60%\"\u002F>\n        \u003Cfigcaption> The \u003Cb>Siamese Network\u003C\u002Fb> passes both images through\n        the embedding network and then does the correlation between the embeddings, as shown below.\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>        \n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_4537a0e2a7a5.gif\" height=\"50%\" width=\"50%\">\n        \u003Cfigcaption> The peak of the \u003Cb>correlation map\u003C\u002Fb> is supposed to be \n        located at the center of the map (because the images are both centered in the target).\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_ed78b3e89abc.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>Here we overlay the correlation map with the search image, the peak value indicates the estimated center position of the target.\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n### Results - Training\n\nThe only training metric comparable between different parameters and implementations is the average *center error*  (or *center displacement*). The authors provide this metric in **appendix B** of their paper [Learning feed-forward one-shot learners](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1606.05233.pdf), which is 7.40 pixels for validation and 6.26 pixels for training.\n\nOur Baseline Results are shown below:\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_180d6f3c9c9e.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption>\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\nWe are around 4 pixels behind the authors, which we hypothesize that is mainly due to:\n\n* The lack of a bicubic upscaling layer on the correlation map, which effectively causes our correlation map to have a resolution 4 times lower than the original image (due to the network's stride).\n* The lack of class normalization of the loss to deal with the unbalance between negative and positive elements on the correlation map label (way more negative than positive positions). \n\nOn the other hand, **we are way less prone to overfitting**, because we sample the pairs differently on each training epoch, as opposed to the authors, that choose all the pairs beforehand and use the same pairs on each training epoch.\n\nThis trained model is made available as *BaselinePretrained.pth.tar*.\n\n### How to Run - Training\n\n1. **Prerequisites:** The project was built using **python 3.6** and tested on Ubuntu 16.04 and 17.04. It was tested on a **GTX 1080 Ti** and a **GTX 950M**. Furthermore it requires [PyTorch 4.1](https:\u002F\u002Fpytorch.org\u002F). The rest of the dependencies can be installed with:  \n```\n# Tested on scipy 1.1.0\npip install scipy\n# Tested on scikit-learn 0.20.0\npip install scikit-learn \n# Tested on tqdm 4.26.0\npip install tqdm\n# Tested on tensorboardx 1.4\npip install tensorboardx\n# Tested on imageio 2.4.1\npip install imageio\n# To run the TensorBoard files later on install TensorFlow. \npip install tensorflow\n\n# To run the visualization app you need PyQt5 and pyqtgraph\n# Tested on pyqt 5.6.0 \npip install pyqt5\n# Tested on pyqtgraph 0.10.0\npip install pyqtgraph\n```\nIn case you have Anaconda, install the conda virtual environment with:\n```\n# Used conda 4.5.11\nconda env create -f environment.yaml\nconda activate siamfc\n\n# The pyqtgraph is not included and needs to be installed with pip\npip install pyqtgraph\n\n```\n\n(**OPTIONAL:** To accelerate the dataloading refer to [this section](#accelerating-data-loading))\n\n2. Download the ImageNet VID Dataset in http:\u002F\u002Fbvisionweb1.cs.unc.edu\u002FILSVRC2017\u002Fdownload-videos-1p39.php and extract it on the folder of your choice (*OBS: data reading is done in execution time, so if available extract the dataset in your SSD partition*). You can get rid of the *test* part of the dataset, since it has no Annotations. \n\n3. For each new training we must create an *experiment folder* (the folder stores the training parameters and the training output):\n```\n# Go to the experiments folder\ncd training\u002Fexperiments\n# Create your experiment folder named \u003CEXP_NAME>\nmkdir \u003CEXP_NAME>\n# Copy the parameter file from the default experiment folder\ncp default\u002Fparameters.json \u003CEXP_NAME>\u002F\n```\n4. Edit the *parameters.json* file with the desired parameters. The description of each parameter can be found [here](#training-parameters).\n5. Run the *train.py* script:\n```\n# \u003CEXP_NAME> is the name of the experiment folder, NOT THE PATH. \npython train.py --data_dir \u003CFULL_PATH_TO_DATASET_ROOT> --exp_name \u003CEXP_NAME>\n```\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9bc51804992a.gif\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption>This gif illustrates the execution of the training script. It uses very few epochs just to give a feel of the execution. A serious training execution could take a whole day.\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\n* Use `--time` in case you want to profile the execution times. They will be saved in the train.log file.\n\n6. The outputs will be:\n* `train.log`: The log of the training, most of which is also displayed in the terminal.\n* `metadata.train` and `metadata.val`: The metadata of the training and validation datasets, which is written on the start of the program. **Simply copy these files to any new experiment folder to save time on set up (about 15 minutes in my case).**      \n* `metrics_val_last_weights.json`: The json containing the metrics of the most recent validation epoch. Human readable.  \n* `metrics_val_best_weights.json`: The json containing the metrics of the validation epoch with the best AUC score. Human readable.   \n* `best.pth.tar` and `last.pth.tar`: Dictionary containing the state_dictionary among other informations about the model. Can be loaded again later, for\ntraining, validation or inference. Again *last* is the current epoch and *best* is the best one.   \n* `tensorboard`: Folder containing the **tensorboard** files summarizing the training. It is separated in a *val* and a *train* folder so that the curves can be plotted in the same plot. To launch it type: \n```\n# You need TensorFlow's TensorBoard installed to do so.\ntensorboard --logdir \u003Cpath_to_experiment_folder>\u002Ftensorboard \n``` \n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_ce4f7cc5a5a8.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>The three metrics stored are the mean \u003Cb>AUC\u003C\u002Fb> of the the ROC curve of the binary classification error between the label correlation map (defined by the parameters) and the actual correlation map, as well as the \u003Cb>Center Error\u003C\u002Fb>, which is the distance in pixels between the peak position of the correlation map and the actual center. Lastly, we also plot the mean \u003Cb>Binary Cross-Entropy Loss\u003C\u002Fb>, used to optimize the model.\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n**OBS**: Our definition of the loss is slightly different than the author's, but should be equivalent. Refer to [Loss Definition](#loss-definition).\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9ff3f0cb1b69.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>We also store Ref\u002FSearch\u002FCorrelation Map trios for each epoch, for debugging and exploration reasons. They are collected in each validation epoch, thus the first image corresponds to the validation before th e first training epoch. They allow us to see the evolution of the network's estimation after each training epoch. \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n**OBS:** To set the number of trios stored in each epoch, use the `--summary_samples \u003CNUMBER_OF_TRIOS>` flag:\n```\npython train.py -s 10 -d \u003CFULL_PATH_TO_DATASET_ROOT> -e \u003CEXP_NAME> \n```\nThe images might take a lot of space though, especially if the number of epochs is large.\n\n### Additional Uses\n\n#### Retraining\u002FLoading Pretrained Weights\n\nYou can continue training a network or load pretrained weights by calling the train script with the flag `--restore_file \u003CNAME_OF_MODEL>` where \u003CNAME_OF_MODEL> is the filename **without** the *.pth.tar* extension (e.g. *best*, for *best.pth.tar*). The program then searchs for the file NAME_OF_MODEL.pth.tar inside the experiment folder and loads its state as the initial state, the rest of the training script continues normally.  \n```\npython train.py -r \u003CNAME_OF_MODEL> -d \u003CFULL_PATH_TO_DATASET_ROOT> -e \u003CEXP_NAME>\n```\n\n#### Evaluation Only\n\nOnce you finished training and dispose of a *.pth.tar file containing the network's weigths, you can evaluate it on the dataset by using the `--mode eval` combined with `--restore_file \u003CNAME_OF_MODEL>`:\n```\npython train.py -m eval -r \u003CNAME_OF_MODEL> -d \u003CFULL_PATH_TO_DATASET_ROOT> -e \u003CEXP_NAME>\n```\nThe results of the evaluation are then stored in `metrics_test_best.json`.\n\n\n### Tracking\n\n[Under Development]\n\n## Datasets\n\nThe dataset used for the tracker evaluation is a compilation of sequences from\nthe datasets [TempleColor](http:\u002F\u002Fwww.dabi.temple.edu\u002F~hbling\u002Fdata\u002FTColor-128\u002FTColor-128.html),\n[VOT2013, VOT2014, and VOT2016](http:\u002F\u002Fwww.votchallenge.net\u002Fchallenges.html). The Temple\nColor and VOT2013 datasets are annotated with upright rectangular bounding boxes\n(4 numbers), while VOT2014 and VOT2016 are annotated with rotated bounding boxes\n(8 numbers). The order of the annotations seems to be the the following:\n\n* TC: LowerLeft(x , y), Width, Height\n* VOT2013: LowerLeft(x, y), Width, Height\n* VOT2014: UpperLeft(x, y), LowerLeft(x, y), LowerRight(x, y), UpperRight(x, y)\n* VOT2016: LowerLeft(x, y), LowerRight(x, y), UpperRight(x, y), UpperLeft(x, y)\n\nOBS: It is possible that the annotations in VOT204 and 2016 simply represent a\nsequence of points that define the contour of the bounding box, in no particular\norder (but respecting the adjency of the the points in the rectangle). I didn't\ncheck all the ground-truths to guarantee that all the annotations are in the\nparticular order described here. If something goes very wrong, you might want to\nconfirm this.\n\nThe dataset used for the training is the 2015 ImageNet VID, which contains\nvideos of targets where each frame is labeled with a bounding box around the\ntargets.\n\n## Visualization Application\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_8ad42491239e.gif\" height=\"60%\" width=\"80%\">\n        \u003Cfigcaption>\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\nI've also developped a visualization application to see the output of the network in real time. The objective is to observe the merits and limitations of the network **as a similarity function**, **NOT** to evaluate nor visualize the complete tracker.\n\nThe vis_app simply compares the reference embedding **with the whole frame** for each frame in a given sequence, instead of comparing it with a restricted area like the tracker. The basic pipeline is:\n\n* Get the first frame in which the target appears.\n* Calculate a resizing factor such that the reference image (bounding box + context region) has 127 pixels, just as during training. All the subsequent frames will be resized as well.\n* Pass the reference image through the embedding branch to get the reference embedding. There is **no update** of the reference embedding.\n* For each frame of the sequence we patch the sides with zeros, so that the output dimensions of the score map have the same dimensions as the frame itself.\n* Convolve the the ref embedding with the frame's embedding (which can be quite big) to get the full score map. The score map is upscaled to \"undo\" the effect of the stride and is overlaid over the frame. The score map's intensity is encoded to color with the [inferno colormap](https:\u002F\u002Fmatplotlib.org\u002Fusers\u002Fcolormaps.html).\n* We also plot in each frame the peak of the score map as the network's guess of the current target position. We plot the Center Error curve as well.     \n\nThe application is implemented using two threads: the **display thread** that takes care of the GUI and the **producer thread** that does all the computations. \n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_8eab80966d9c.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption> In the top of the window we show the current fps rate of the display; the visibility status of the target (true if the target is inside the frame); and the number of frames in the buffer that stores the frames produced by the produced thread. \n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_a66e42b7ecf9.png\" height=\"60%\" width=\"80%\">\n        \u003Cfigcaption> In the bottom of this image we have the full path to the current frame; the reference image shows the image being used as reference by the network; The ground truth shows the current frame with the bounding box overlaid; and the Score Map shows the score map calculated by the network over the current frame, the amount of each can be controlled with an \u003Cb>alpha argument\u003C\u002Fb>. A green cross is placed in the peak of the score map.\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9a008f69ede4.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption> Finally we have a plot of the Center Error per frame, being the distance between the score map's peak and the center of the ground thruth bounding box. We Draw a blue line in 63 pixels (half of the Reference Image side), that serves as a threshold over which the position might be outside the bounding box. \n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n### How to Run - Visualization Application\n\nAssuming the ImageNet VID dataset is the path \\\u003CILSVRC>, and that the PyQt5 and pyqtgraph packages are installed: \n```\n# -d is the path to the dataset and -n the path to the model's file.\npython vis_app.py -d \u003CILSVRC> -n BaselinePretrained.pth.tar -t train -s 10\n```\nAlso, the sequences are separated into `train` and `val` sequences according to the dataset's organization, and numbered in increasing order. So to get the 150th training sequence, use the arguments `-t train -s 149` (index starts at zero). The `train` sequences range from 0 to 3861 and the `val` from 0 to 554.\n\nYou can also set the alpha value from 0.0 to 1.0, that controls how much of the frame is overlaid with the score map. To get the score map without the frame behind it use the argument `-a 1`. To see all the arguments use `python vis_app.py -h`   \n\n\n## Parameters\n\nBoth tracking and training scripts are defined in terms of user-defined parameters,\nwhich define much of their behaviour. The parameters are defined inside .json files\nand can be directly modified by the user. In both tracking and training a given\nset of parameters defines what we call an `experiment` and thus they are placed\ninside folders called experiments inside both training and tracking.\nTo define new parameters for a new experiment, copy the default experiment folder\nwith its .json files and name it accordingly, placing it always inside the\ntraining(or tracking)\u002Fexperiments folder. Here below we give a brief description\nof the basic parameters:\n\n### Training Parameters:\n\n* `model`: The Embedding Network to be used as the branch of the Siamese Network, the models are defined in [models.py](training\u002Fmodels.py). The models available are *BaselineEmbeddingNet*, *VGG11EmbeddingNet_5c*, *VGG16EmbeddingNet_8c*.\n* `parameter_freeze`: A list of the layers of the Embedding Net that will be frozen (parameters will not be change). The numeration refers the *nn.Sequential* class that defines the Network in [models.py](training\u002Fmodels.py). E.g. [0, 1, 4, 5] with *BaselineEmbeddingNet* freezes the two first convolutional layers (0 and 4) along with the two first BatchNorm layers (1 and 5).\n* `batch_size`: The batch size in terms of reference\u002Fsearch region pairs. The\n    authors of the paper suggested using a batch of 8 pairs.\n* `num_epochs`: Total number of training epochs. One validation epoch is done before training starts and after each training epoch.\n* `train_epoch_size`: The number of iterations for each train epoch. If it is\n    bigger than the total number of frames in the dataset, the epoch size\n    defaults to the whole dataset, warning the user of it.\n* `eval_epoch_size`: The number of iterations for each validation epoch. If it\n    is bigger than the total number of frames in the dataset, the epoch size\n    defaults to the whole dataset, warning the user of it.\n* `save_summary_steps`: The number of batches between the metrics evaluation.\n    If set to 0 all batches are evaluated in terms of the metrics after the\n    loss is calculated. If set to 10, every tenth batch is evaluated.\n* `optim`: The optimizer to be used during training. Options include *SGD* for\n    stochastic gradient descent, and *Adam* for Adaptative Momentum.\n* `optim_kwargs`: The keywords associated with each optimizer's initialization.\n    It is itself a dictionary, and should follow the pytorch documentation.\n    For example, if optim is `SGD` we could specify it as\n    {`lr`: 1e-3, `momentum`:0.9}, for a learning rate of 0.001 and momentum\n    of 0.9. Each optimizer has its available keywords, cf.\n    https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Foptim.html for more info.\n* `max_frame_sep`: The maximum frame separation, the maximum distance between\n    frames in each pairs chosen by the dataset. Default value is 50.\n* `reference_sz`: The reference region size in pixels. Default is 127.\n* `search_sz`: The search region size in pixels. Default is 255.\n* `final_sz`: The final size after the pairs are passed throught the model.\n* `upscale`: A boolean to indicate if the network should have a bilinear upscale\n    layer. OBS: Might slow training a lot.\n* `pos_thr`: The positive threshold distance in the label, the threshold of\n    the distance to the center that is considered a positive pixel.\n* `neg_thr`: The negative threshold distance in the label, the threshold of\n    the distance to the center that is considered a negative pixel. Every\n    pixel with a distance between the positive and negative thresholds is\n    considered neutral, and is not penalised either way.\n* `context_margin`: The context margin for the reference region.\n\n\n### Tracking Parameters:\n\n[Under Development]\n\n### Accelerating Data Loading\n\n[Coming Soon]\n\n### Loss Definition\n\n[Coming Soon]\n\nACKNOWLEDGEMENTS:\nThis project was originally developed and open-sourced by Parrot Drones SAS.\n","# SiameseFC PyTorch实现\n\n## 简介\n\n本项目是论文《用于目标跟踪的全卷积孪生网络》中提出的目标跟踪器的PyTorch实现，该论文发表于[arXiv](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1606.09549.pdf)，相关项目页面请见[这里](https:\u002F\u002Fwww.robots.ox.ac.uk\u002F~luca\u002Fsiamese-fc.html)。原始版本使用Matlab结合MatConvNet框架编写，代码可在[这里](https:\u002F\u002Fgithub.com\u002Fbertinetto\u002Fsiamese-fc)找到（包含训练和跟踪部分），而本Python版本则基于TensorFlow移植版（仅跟踪部分）改编而来，该TensorFlow版本的代码可参见[这里](https:\u002F\u002Fgithub.com\u002Ftorrvision\u002Fsiamfc-tf)。\n\n## 项目结构\n\n该项目主要分为三个部分：[**训练**](#training)、[**跟踪**](#tracking)以及[**可视化应用**](#visualization-application)。\n\n## 训练\n\n本工作的核心在于**训练**部分，即通过训练孪生网络来学习补丁之间的相似性度量，这在论文中有详细描述。\n\n\u003Ccenter>\n    \u003Cfigure>    \n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_e7742ce1131d.png\" height=\"50%\" width=\"60%\"\u002F>\n        \u003Cfigcaption> **孪生网络** 将两张图像分别输入嵌入网络，随后对两个嵌入特征进行相关性计算，如下图所示。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>        \n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_4537a0e2a7a5.gif\" height=\"50%\" width=\"50%\">\n        \u003Cfigcaption> **相关性图** 的峰值应位于图的中心位置（因为两张图像中的目标都处于中心位置）。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_ed78b3e89abc.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>此处我们将相关性图与搜索图像叠加，峰值位置即为目标的估计中心位置。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n### 训练结果\n\n不同参数和实现之间唯一可比较的训练指标是平均*中心误差*（或称*中心位移*）。作者在其论文《学习前馈式一次性学习者》的附录B中提供了这一指标，其中验证集上的平均中心误差为7.40像素，训练集上则为6.26像素。\n\n我们的基准结果如下：\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_180d6f3c9c9e.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption>\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n我们与作者的结果相比大约落后4像素，我们认为主要原因包括：\n\n* 相关性图缺少双三次上采样层，导致相关性图的分辨率仅为原图的四分之一（由于网络的步幅所致）。\n* 损失函数中缺乏类别归一化处理，无法有效应对相关性图标签中负样本与正样本数量极不平衡的问题（负样本远多于正样本）。\n\n另一方面，**我们的模型过拟合风险更低**，因为我们每次训练时都会随机采样不同的图像对，而作者则是在训练开始前就固定了所有图像对，并在每次训练中重复使用相同的图像对。\n\n本训练得到的模型以`BaselinePretrained.pth.tar`的形式提供。\n\n### 如何运行 - 训练\n\n1. **先决条件：** 本项目使用**Python 3.6**开发，并在Ubuntu 16.04和17.04系统上进行了测试。硬件方面，我们在**GTX 1080 Ti**和**GTX 950M**显卡上进行了测试。此外，还需要安装[PyTorch 4.1](https:\u002F\u002Fpytorch.org\u002F)。其余依赖库可通过以下命令安装：\n```\n# 经测试使用的scipy版本为1.1.0\npip install scipy\n# 经测试使用的scikit-learn版本为0.20.0\npip install scikit-learn \n# 经测试使用的tqdm版本为4.26.0\npip install tqdm\n# 经测试使用的tensorboardx版本为1.4\npip install tensorboardx\n# 经测试使用的imageio版本为2.4.1\npip install imageio\n# 若后续需要运行TensorBoard文件，则需安装TensorFlow。\npip install tensorflow\n\n# 若要运行可视化应用，则需要PyQt5和pyqtgraph。\n# 经测试使用的pyqt版本为5.6.0\npip install pyqt5\n# 经测试使用的pyqtgraph版本为0.10.0\npip install pyqtgraph\n```\n若使用Anaconda，可通过conda虚拟环境安装依赖：\n```\n# 使用conda 4.5.11版本\nconda env create -f environment.yaml\nconda activate siamfc\n\n# PyQtGraph未包含在conda环境中，需通过pip单独安装。\npip install pyqtgraph\n\n```\n\n(**可选：** 如需加速数据加载，请参考[本节](#accelerating-data-loading)）\n\n2. 从http:\u002F\u002Fbvisionweb1.cs.unc.edu\u002FILSVRC2017\u002Fdownload-videos-1p39.php下载ImageNet VID数据集，并将其解压到您选择的文件夹中（注意：数据读取是在运行时完成的，因此建议将数据集解压到SSD分区以提高效率）。您可以删除数据集中的“test”部分，因为它没有标注信息。\n\n3. 每次新的训练都需要创建一个*实验文件夹*（该文件夹用于存储训练参数和输出结果）：\n```\n# 进入experiments文件夹\ncd training\u002Fexperiments\n# 创建名为\u003CEXP_NAME>的实验文件夹\nmkdir \u003CEXP_NAME>\n# 将默认实验文件夹中的参数文件复制到新文件夹中\ncp default\u002Fparameters.json \u003CEXP_NAME>\u002F\n```\n4. 根据需求编辑`parameters.json`文件。每个参数的说明可在[此处](#training-parameters)找到。\n\n5. 运行`train.py`脚本：\n```\n# \u003CEXP_NAME>是实验文件夹的名称，而非路径。\npython train.py --data_dir \u003CFULL_PATH_TO_DATASET_ROOT> --exp_name \u003CEXP_NAME>\n```\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9bc51804992a.gif\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption>此动图展示了训练脚本的执行过程。这里仅使用了少量epoch以便演示，实际的完整训练可能需要一整天的时间。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\n* 如果需要分析执行时间，可以添加`--time`参数，执行时间将被记录在`train.log`文件中。\n\n6. 训练完成后，将生成以下输出文件：\n* `train.log`：训练日志，其中大部分内容也会显示在终端中。\n* `metadata.train`和`metadata.val`：训练集和验证集的元数据，这些文件会在程序启动时自动生成。**只需将这些文件复制到任何新的实验文件夹中，即可节省约15分钟的设置时间（对我而言如此）。**\n* `metrics_val_last_weights.json`：包含最近一次验证epoch指标的JSON文件，便于阅读。\n* `metrics_val_best_weights.json`：包含AUC得分最高那次验证epoch指标的JSON文件，同样便于阅读。\n* `best.pth.tar`和`last.pth.tar`：包含模型状态字典及其他相关信息的文件，可用于后续的训练、验证或推理。其中`last`表示当前epoch的模型权重，而`best`则表示AUC得分最高的模型权重。\n* `tensorboard`：包含总结训练过程的TensorBoard文件夹，分为`val`和`train`两个子文件夹，以便在同一张图中绘制曲线。要启动TensorBoard，可输入以下命令：\n\n# 为此，您需要安装 TensorFlow 的 TensorBoard。\ntensorboard --logdir \u003C实验文件夹路径>\u002Ftensorboard \n``` \n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_ce4f7cc5a5a8.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>存储的三个指标分别是：标签相关图（由参数定义）与实际相关图之间二分类误差的 ROC 曲线的平均\u003Cb>AUC\u003C\u002Fb>；\u003Cb>中心误差\u003C\u002Fb>,即相关图峰值位置与实际中心之间的像素距离；以及用于优化模型的平均\u003Cb>二元交叉熵损失\u003C\u002Fb>。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n**注**: 我们的损失函数定义与作者略有不同，但应具有等价性。请参阅[损失函数定义](#loss-definition)。\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9ff3f0cb1b69.png\" height=\"60%\" width=\"60%\">\n        \u003Cfigcaption>我们还会为每个 epoch 存储参考\u002F搜索\u002F相关图三联图，以便调试和探索。这些图像会在每个验证 epoch 收集，因此第一张图对应的是第一个训练 epoch 之前的验证结果。它们可以帮助我们观察网络在每个训练 epoch 后对结果估计的变化过程。\u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n**注:** 若要设置每个 epoch 存储的三联图数量，请使用 `--summary_samples \u003C三联图数量>` 标志：\n```\npython train.py -s 10 -d \u003C数据集根目录完整路径> -e \u003C实验名称> \n```\n不过，这些图像可能会占用大量空间，尤其是在 epoch 数量较多时。\n\n### 其他用途\n\n#### 继续训练\u002F加载预训练权重\n\n您可以通过调用训练脚本并添加 `--restore_file \u003C模型名称>` 标志来继续训练网络或加载预训练权重，其中 `\u003C模型名称>` 是文件名，**不包含** *.pth.tar* 扩展名（例如 *best*，对应 *best.pth.tar*）。程序随后会在实验文件夹中查找名为 `NAME_OF_MODEL.pth.tar` 的文件，并将其状态作为初始状态加载，其余训练流程将正常进行。  \n```\npython train.py -r \u003C模型名称> -d \u003C数据集根目录完整路径> -e \u003C实验名称>\n```\n\n#### 仅评估\n\n完成训练并获得包含网络权重的 *.pth.tar* 文件后，您可以通过结合 `--mode eval` 和 `--restore_file \u003C模型名称>` 来对该模型在数据集中进行评估：\n```\npython train.py -m eval -r \u003C模型名称> -d \u003C数据集根目录完整路径> -e \u003C实验名称>\n```\n评估结果将被存储在 `metrics_test_best.json` 中。\n\n\n### 跟踪\n\n[开发中]\n\n## 数据集\n\n用于跟踪器评估的数据集是由以下数据集中的序列汇编而成：\n[TempleColor](http:\u002F\u002Fwww.dabi.temple.edu\u002F~hbling\u002Fdata\u002FTColor-128\u002FTColor-128.html)、\n[VOT2013、VOT2014 和 VOT2016](http:\u002F\u002Fwww.votchallenge.net\u002Fchallenges.html)。Temple Color 和 VOT2013 数据集采用直立矩形边界框标注（4 个数字），而 VOT2014 和 VOT2016 则采用旋转边界框标注（8 个数字）。标注顺序大致如下：\n\n* TC：左下角(x , y)，宽度，高度\n* VOT2013：左下角(x, y)，宽度，高度\n* VOT2014：左上角(x, y)，左下角(x, y)，右下角(x, y)，右上角(x, y)\n* VOT2016：左下角(x, y)，右下角(x, y)，右上角(x, y)，左上角(x, y)\n\n**注**: VOT2014 和 VOT2016 中的标注也可能只是按任意顺序列出的一系列点，用来定义边界框的轮廓，但这些点必须符合矩形的相邻关系。我并未检查所有真实标签以确保所有标注都按照此处描述的特定顺序排列。如果出现严重问题，您可能需要再次确认这一点。\n\n用于训练的数据集是 2015 年 ImageNet VID，其中包含目标视频，每帧都用边界框标记了目标。\n\n## 可视化应用\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_8ad42491239e.gif\" height=\"60%\" width=\"80%\">\n        \u003Cfigcaption>\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n我还开发了一个可视化应用，用于实时查看网络的输出。其目的是观察该网络作为**相似度函数**的优点和局限性，**而非**评估或可视化整个跟踪器。\n\nvis_app 会针对给定序列中的每一帧，将参考嵌入与**整张帧**进行比较，而不是像跟踪器那样只在受限区域内进行比较。基本流程如下：\n\n* 获取目标首次出现的第一帧。\n* 计算一个缩放因子，使得参考图像（边界框 + 上下文区域）的尺寸为 127 像素，与训练时一致。后续所有帧也将按此比例缩放。\n* 将参考图像输入嵌入分支，得到参考嵌入。**不更新**参考嵌入。\n* 对于序列中的每一帧，我们在图像边缘填充零，以使得分图的输出尺寸与当前帧尺寸相同。\n* 将参考嵌入与当前帧的嵌入（可能非常大）进行卷积，得到完整的得分图。然后对得分图进行上采样，以抵消步幅的影响，并将其叠加到当前帧上。得分图的强度通过 [inferno 颜色映射](https:\u002F\u002Fmatplotlib.org\u002Fusers\u002Fcolormaps.html) 转换为颜色显示。\n* 我们还在每一帧中标出得分图的峰值位置，作为网络对当前目标位置的预测。同时绘制中心误差曲线。\n\n该应用采用两个线程实现：负责 GUI 的**显示线程**和执行所有计算的**生产者线程**。\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_8eab80966d9c.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption> 窗口顶部显示当前的显示帧率；目标是否可见的状态（如果目标在帧内则为真）；以及存储生产者线程生成帧的缓冲区中当前的帧数。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_a66e42b7ecf9.png\" height=\"60%\" width=\"80%\">\n        \u003Cfigcaption> 图片底部显示当前帧的完整路径；参考图像显示网络当前使用的参考图像；真实标签显示当前帧及其叠加的边界框；得分图显示网络在当前帧上计算出的得分图，各部分的透明度可通过\u003Cb>alpha 参数\u003C\u002Fb>控制。得分图的峰值处会标记一个绿色十字。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n\u003Ccenter>\n    \u003Cfigure>\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_readme_9a008f69ede4.png\" height=\"60%\" width=\"100%\">\n        \u003Cfigcaption> 最后是每帧的中心误差曲线，表示得分图峰值与真实标签边界框中心之间的距离。我们还绘制了一条蓝色水平线，位于 63 像素处（即参考图像边长的一半），作为判断目标位置是否超出边界框的阈值。\n        \u003C\u002Ffigcaption>\n    \u003C\u002Ffigure>\n\u003C\u002Fcenter>\n\n### 如何运行——可视化应用\n\n假设 ImageNet VID 数据集的路径为 \\\u003CILSVRC>, 并且已安装 PyQt5 和 pyqtgraph 包，则可运行以下命令：\n```\n# -d 指定数据集路径，-n 指定模型文件路径。\npython vis_app.py -d \u003CILSVRC> -n BaselinePretrained.pth.tar -t train -s 10\n```\n此外，数据集按照 `train` 和 `val` 分别组织序列，并按顺序编号。因此，要获取第 150 个训练序列，需使用参数 `-t train -s 149`（索引从 0 开始）。`train` 序列的编号范围为 0 到 3861，`val` 序列的编号范围为 0 到 554。\n\n您还可以设置 alpha 值，取值范围为 0.0 到 1.0，用于控制得分图覆盖帧的比例。若希望仅显示得分图而不显示背景帧，可使用参数 `-a 1`。如需查看所有可用参数，可运行 `python vis_app.py -h`。\n\n\n## 参数\n\n无论是跟踪脚本还是训练脚本，其行为都由用户定义的参数决定。这些参数存储在 .json 文件中，用户可以直接修改。对于跟踪和训练任务而言，一组特定的参数即构成一次“实验”，因此它们会被放置在训练和跟踪目录下的 `experiments` 文件夹中。若要为新实验定义参数，只需复制默认的实验文件夹及其 .json 文件，并根据需要重命名，然后将其放入 `training` 或 `tracking` 目录下的 `experiments` 文件夹中即可。以下简要介绍一些基本参数：\n\n### 训练参数：\n\n* `model`: 用作孪生网络分支的嵌入网络，模型定义在 [models.py](training\u002Fmodels.py) 中。可用的模型包括 *BaselineEmbeddingNet*、*VGG11EmbeddingNet_5c* 和 *VGG16EmbeddingNet_8c*。\n* `parameter_freeze`: 嵌入网络中需要冻结的层列表（即这些层的参数不会被更新）。编号对应于 [models.py](training\u002Fmodels.py) 中定义网络的 `nn.Sequential` 类。例如，对于 `BaselineEmbeddingNet`，[0, 1, 4, 5] 表示冻结前两层卷积层（0 和 4）以及前两层批归一化层（1 和 5）。\n* `batch_size`: 以参考\u002F搜索区域对为单位的批量大小。论文作者建议使用 8 对的批量。\n* `num_epochs`: 总训练轮数。在训练开始前以及每一轮训练结束后都会进行一次验证。\n* `train_epoch_size`: 每个训练轮次的迭代次数。如果该值大于数据集中帧的总数，则轮次大小将默认设置为整个数据集，并向用户发出警告。\n* `eval_epoch_size`: 每个验证轮次的迭代次数。如果该值大于数据集中帧的总数，则轮次大小将默认设置为整个数据集，并向用户发出警告。\n* `save_summary_steps`: 在评估指标之前经过的批次数量。若设置为 0，则在计算损失后会对所有批次的指标进行评估；若设置为 10，则每 10 个批次评估一次。\n* `optim`: 训练过程中使用的优化器。可选的有随机梯度下降法（SGD）和自适应矩估计法（Adam）。\n* `optim_kwargs`: 与各优化器初始化相关的关键字参数。它本身是一个字典，应遵循 PyTorch 的文档说明。例如，若优化器为 `SGD`，则可以指定为 {`lr`: 1e-3, `momentum`:0.9}，表示学习率为 0.001，动量为 0.9。每种优化器都有其可用的关键字，更多信息请参阅：https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Foptim.html。\n* `max_frame_sep`: 最大帧间间隔，即数据集中每对帧之间允许的最大距离。默认值为 50。\n* `reference_sz`: 参考区域的尺寸，单位为像素。默认值为 127。\n* `search_sz`: 搜索区域的尺寸，单位为像素。默认值为 255。\n* `final_sz`: 将成对的图像输入模型后得到的最终输出尺寸。\n* `upscale`: 一个布尔值，用于指示网络是否应包含双线性上采样层。注意：这可能会显著减慢训练速度。\n* `pos_thr`: 标签中的正样本阈值距离，即被视为正样本像素的距离上限。\n* `neg_thr`: 标签中的负样本阈值距离，即被视为负样本像素的距离下限。任何距离介于正负阈值之间的像素都被视为中性像素，既不计入正样本也不计入负样本。\n* `context_margin`: 参考区域的上下文边距。\n\n\n### 跟踪参数：\n\n[开发中]\n\n### 加速数据加载\n\n[即将推出]\n\n### 损失函数定义\n\n[即将推出]\n\n致谢：\n本项目最初由 Parrot Drones SAS 开发并开源。","# Pytorch-SiamFC 快速上手指南\n\nPytorch-SiamFC 是经典目标跟踪算法 **SiameseFC** 的 PyTorch 实现版本。该项目主要用于训练孪生网络以学习图像块之间的相似度度量，并提供了可视化工具来观察网络输出。\n\n## 1. 环境准备\n\n本项目基于 **Python 3.6** 开发，已在 Ubuntu 16.04\u002F17.04 系统上测试通过。推荐使用 NVIDIA GPU（如 GTX 1080 Ti 或 GTX 950M）进行加速。\n\n### 核心依赖\n*   **PyTorch**: 版本需为 0.4.1 (注意：原文标注为 4.1，但结合上下文及历史版本，实际指 0.4.1)\n*   **其他库**: scipy, scikit-learn, tqdm, tensorboardx, imageio\n*   **可选库** (用于可视化): tensorflow (用于 TensorBoard), PyQt5, pyqtgraph\n\n### 国内加速建议\n在中国大陆地区，建议使用清华源或阿里源加速 `pip` 和 `conda` 包的下载。\n\n## 2. 安装步骤\n\n### 方案 A：使用 Conda 虚拟环境（推荐）\n\n如果你已安装 Anaconda 或 Miniconda，这是最简便的方式。\n\n1.  **创建并激活环境**：\n    ```bash\n    conda env create -f environment.yaml\n    conda activate siamfc\n    ```\n\n2.  **安装缺失的可视化依赖**（`environment.yaml` 中未包含）：\n    ```bash\n    pip install pyqtgraph -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n\n### 方案 B：手动安装依赖\n\n如果不使用 Conda，请确保 Python 版本为 3.6，然后执行以下命令安装依赖（已配置国内镜像源）：\n\n```bash\n# 安装基础科学计算库\npip install scipy scikit-learn tqdm tensorboardx imageio -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n# 安装 PyTorch (请根据具体 CUDA 版本前往 pytorch.org 获取对应命令，此处为通用示例)\n# 注意：原项目依赖较旧的 PyTorch 0.4.1，若遇兼容性问题可能需要调整版本\npip install torch==0.4.1 torchvision==0.2.1 -i https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu90\n\n# 安装 TensorFlow (仅用于运行 TensorBoard)\npip install tensorflow==1.12.0 -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n# 安装可视化工具依赖\npip install pyqt5 pyqtgraph -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 数据集准备\n训练需要使用 **ImageNet VID 2015** 数据集。\n1.  下载地址：[ILSVRC2017 Video Detection](http:\u002F\u002Fbvisionweb1.cs.unc.edu\u002FILSVRC2017\u002Fdownload-videos-1p39.php)\n2.  解压到任意目录（**建议解压至 SSD 固态硬盘**以提升读取速度）。\n3.  可删除数据集中的 `test` 部分，因为该部分不包含标注信息。\n\n## 3. 基本使用\n\n以下流程演示如何从头开始训练一个模型。\n\n### 第一步：创建实验文件夹\n在 `training\u002Fexperiments` 目录下创建一个新的实验文件夹，并复制默认参数文件。\n\n```bash\ncd training\u002Fexperiments\nmkdir \u003CEXP_NAME>\ncp default\u002Fparameters.json \u003CEXP_NAME>\u002F\n```\n*请将 `\u003CEXP_NAME>` 替换为你自定义的实验名称（例如 `my_first_trial`）。*\n\n### 第二步：配置参数\n编辑 `\u003CEXP_NAME>\u002Fparameters.json` 文件，根据你的需求修改训练参数（如学习率、批次大小等）。具体参数说明可参考项目文档中的 \"Training Parameters\" 部分。同时，请在文件中或命令行指定数据集路径。\n\n### 第三步：启动训练\n运行 `train.py` 脚本开始训练。\n\n```bash\n# 语法：python train.py --data_dir \u003C数据集根目录绝对路径> --exp_name \u003C实验文件夹名称>\npython train.py --data_dir \u002Fhome\u002Fuser\u002Fdatasets\u002FILSVRC2015 --exp_name my_first_trial\n```\n\n**训练输出说明：**\n*   `train.log`: 终端日志的文件备份。\n*   `best.pth.tar` \u002F `last.pth.tar`: 保存的最佳模型权重和最新 epoch 权重。\n*   `tensorboard\u002F`: 包含训练曲线数据。可通过以下命令查看可视化图表：\n    ```bash\n    tensorboard --logdir training\u002Fexperiments\u002F\u003CEXP_NAME>\u002Ftensorboard\n    ```\n\n### 进阶用法\n\n#### 加载预训练权重继续训练\n如果你想基于已有的模型（如 `best.pth.tar`）继续训练：\n```bash\npython train.py --restore_file best --data_dir \u003CFULL_PATH_TO_DATASET_ROOT> --exp_name \u003CEXP_NAME>\n```\n*注意：`--restore_file` 后跟文件名不含 `.pth.tar` 后缀。*\n\n#### 仅进行评估\n如果已有训练好的权重文件，只想在数据集上进行评估：\n```bash\npython train.py --mode eval --restore_file best --data_dir \u003CFULL_PATH_TO_DATASET_ROOT> --exp_name \u003CEXP_NAME>\n```\n评估结果将保存在 `metrics_test_best.json` 中。\n\n#### 可视化应用\n项目包含一个实时可视化工具，用于观察网络作为相似度函数的输出（非完整跟踪器效果）。需确保已安装 `PyQt5` 和 `pyqtgraph`，运行相应的可视化脚本（具体脚本名请参考项目 `visualization-application` 章节，通常为 `vis_app.py` 或类似入口）。","某安防监控团队正在开发一套野外无人机巡检系统，需要实时锁定并跟踪移动的动物目标以进行生态研究。\n\n### 没有 Pytorch-SiamFC 时\n- **开发门槛极高**：原始算法基于 MATLAB 和 MatConvNet 框架，团队成员主要熟悉 Python 生态，跨语言移植代码耗时且容易出错。\n- **推理速度受限**：缺乏高效的深度学习后端支持，在嵌入式设备或普通 GPU 上难以实现流畅的实时视频流处理，帧率远低于需求。\n- **训练调试困难**：无法利用 PyTorch 动态图特性灵活调整网络结构，难以针对特定场景（如遮挡、快速运动）优化相似度度量模型。\n- **可视化缺失**：缺少内置的可视化应用，开发人员只能靠打印日志分析跟踪效果，难以直观判断目标中心点的定位偏差。\n\n### 使用 Pytorch-SiamFC 后\n- **无缝集成开发**：直接复用基于 PyTorch 的实现，团队利用熟悉的 Python 工具链快速完成了模型部署，将集成周期从数周缩短至几天。\n- **实时性能达标**：借助 PyTorch 对 GTX 系列显卡的高效支持，系统在复杂背景下实现了稳定的实时跟踪，满足了无人机端侧的低延迟要求。\n- **灵活迭代优化**：利用其模块化的训练部分，团队轻松修改了采样策略，有效缓解了正负样本不平衡问题，提升了模型在动物快速奔跑时的鲁棒性。\n- **直观效果验证**：通过自带的可视化应用，开发人员能实时看到相关图（Correlation Map）与搜索图像的叠加效果，迅速定位并修复了中心点偏移问题。\n\nPytorch-SiamFC 通过将经典的孪生网络跟踪算法原生化为 Python 生态，极大地降低了高性能物体跟踪技术的落地成本与研发周期。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frafellerc_Pytorch-SiamFC_4537a0e2.gif","rafellerc","Rafael Eller","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Frafellerc_122c2e40.png","Machine Learning Engineer",null,"https:\u002F\u002Fgithub.com\u002Frafellerc",[79,83],{"name":80,"color":81,"percentage":82},"Python","#3572A5",99,{"name":84,"color":85,"percentage":86},"Shell","#89e051",1,634,143,"2026-04-01T18:05:20","NOASSERTION","Linux (Ubuntu 16.04, 17.04)","需要 NVIDIA GPU，已测试 GTX 1080 Ti 和 GTX 950M，未明确具体显存和 CUDA 版本要求","未说明",{"notes":95,"python":96,"dependencies":97},"训练数据需使用 ImageNet VID 数据集，建议解压至 SSD 以提升读取速度。若使用 Anaconda，可通过 environment.yaml 创建虚拟环境。可视化应用依赖 PyQt5 和 pyqtgraph。训练过程可能耗时一整天。","3.6",[98,99,100,101,102,103,104,105,106],"torch==0.4.1","scipy==1.1.0","scikit-learn==0.20.0","tqdm==4.26.0","tensorboardx==1.4","imageio==2.4.1","tensorflow","pyqt5==5.6.0","pyqtgraph==0.10.0",[15,14],[109,110,111,112,113],"siamese-network","tracking","deep-learning","computer-vision","pytorch","2026-03-27T02:49:30.150509","2026-04-19T15:46:30.736508",[117,122,127,131,136,141,146],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},42450,"SiamFC 网络是否适合用于计算两张物体图像（如人脸）之间的相似度匹配？","SiamFC 并不最适合此类问题。跟踪问题假设物体在相邻帧之间外观变化不大，而通用物体匹配通常不具备此假设。建议改用基于嵌入向量（embeddings）之间欧几里得距离的相似度函数，而不是 SiamFC 基于相关性的方法。如果必须使用 SiamFC 且遇到 NaN 或 Inf 结果，请确保输入图像的像素值范围在 [0, 1] 之间，而不是 [0, 255]。也可以参考类似 RepMet 的方法。","https:\u002F\u002Fgithub.com\u002Frafellerc\u002FPytorch-SiamFC\u002Fissues\u002F8",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},42451,"训练时的标签（label）是如何生成的？所有图像共享相同的标签吗？","是的，标签是固定的。标签的大小与输出得分图（score map）的大小一致（例如代码中的 33x33）。标签是根据元素到中心的距离计算的，因此对于所有输入图像，只要输出尺寸固定，标签就是相同的。标签中的元素表示该点属于中心点的概率（通常为 1 或 0），网络计算得分图后与这些固定标签计算损失。","https:\u002F\u002Fgithub.com\u002Frafellerc\u002FPytorch-SiamFC\u002Fissues\u002F12",{"id":128,"question_zh":129,"answer_zh":130,"source_url":126},42452,"训练时每次输入的两张图像必须来自同一个视频序列吗？","不需要。虽然训练数据包含许多不同的图像序列，每个序列跟踪不同的物体，但网络每次训练可以输入来自不同序列的两张图像。并没有强制要求两张图像必须来自同一序列。",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},42453,"损失函数 BCELogit_Loss 的具体数学原理和推导是什么？","原始论文中使用的是逻辑损失 log(1+exp(-yv))，其中 y 是标签（中心点为 1，非中心点为 -1），v 是得分图的输出（无激活函数的卷积输出）。该公式等价于二元交叉熵损失（Binary Cross Entropy, BCE）。具体推导如下：利用恒等式 log(1+exp(-yv)) = -log(sigm(yv))。当 y=1 时，loss = -log(sigm(v))；当 y=-1 时，loss = -log(1 - sigm(v))。若引入变量 w（取值为 0 或 1），损失可重写为 -(w*log(sigm(v)) + (1-w)*log(1-sigm(v)))。代码中使用 BCEWithLogits 是为了在一个步骤中同时计算 Sigmoid 和 BCE，这样输出的得分图数值被限制在 0 到 1 之间，可解释为属于正类的概率。","https:\u002F\u002Fgithub.com\u002Frafellerc\u002FPytorch-SiamFC\u002Fissues\u002F7",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},42454,"为什么 make_score_map 生成的得分图尺寸有时比输入图像大 1 个像素？","这是由于网络中缺乏填充（padding）导致的，这是保持网络“全卷积”特性的必要条件。具体原因是 2D 池化层（大小为 3，步长为 2）没有设置 padding，导致缩放因子不完全是整数 2，从而产生 1 个像素的偏差。偏移量（offset）的计算公式为：(((ref_shape + 1)\u002F\u002F4)*4 - 1)\u002F\u002F2，旨在让最终得分图尺寸尽可能匹配搜索图像。","https:\u002F\u002Fgithub.com\u002Frafellerc\u002FPytorch-SiamFC\u002Fissues\u002F18",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},42455,"模型训练指标很好，但可视化应用（vis_app）结果显示全图均匀粉色且中心误差巨大，可能是什么原因？","这很可能是批归一化（BatchNorm）层的问题。如果在训练和验证时使用了足够多的序列却出现此现象，可能是 Bug。建议尝试从提供的预训练模型（BaselinePretrained.pth.tar）进行微调，看是否能得到正确结果。此外，检查依赖库版本（通过 pip freeze）和训练日志也有助于排查问题。","https:\u002F\u002Fgithub.com\u002Frafellerc\u002FPytorch-SiamFC\u002Fissues\u002F10",{"id":147,"question_zh":148,"answer_zh":149,"source_url":126},42456,"match_corr 函数中为什么没有对得分图应用 Sigmoid 激活函数？","在 training\u002Fmodels.py 的 SiameseNet 类中，match_corr 函数计算两个嵌入向量的相关性。该函数最后一步使用的是批归一化（batchnorm），并没有直接应用 Sigmoid。这是因为在计算损失时（如使用 BCEWithLogitsLoss），Sigmoid 操作通常被合并到损失函数的计算中以增加数值稳定性，或者在后续处理中根据需要再应用。此外，代码中的 upscale 选项默认未设置为 True。",[]]