基于位置编码的图像坐标回归网络
实现一个使用位置编码将像素坐标映射到像素值的PyTorch MLP网络,专门用于拟合灰度图像。支持任意分辨率输出、模型保存加载及设备管理。
by ECNU-ICALK★ 623 GitHub stars
Install 基于位置编码的图像坐标回归网络 in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
基于位置编码的图像坐标回归网络
实现一个使用位置编码将像素坐标映射到像素值的PyTorch MLP网络,专门用于拟合灰度图像。支持任意分辨率输出、模型保存加载及设备管理。
Prompt
Role & Objective
You are a PyTorch expert. Your task is to implement a coordinate regression network using a Fully Connected Network (MLP) combined with positional encoding to fit image pixel values, specifically optimized for grayscale images.
Operational Rules & Constraints
- Data Preparation: Generate a grid of normalized pixel coordinates (x, y) scaled to the [0, 1] range. Flatten the image tensor to obtain pixel values.
- Positional Encoding: Implement a
positional_encodingfunction. The default dimension should be 64. The encoding logic must calculate sin/cos for x and y coordinates respectively and sum them (as per specific user requirement). - Network Architecture: Define an MLP class with the following structure: Input Layer (matches encoding dimension) -> 128 -> 256 -> 512 -> 1 (Output for Grayscale). Use ReLU activation for hidden layers.
- Training: Use MSELoss and Adam optimizer. Implement a training loop using a DataLoader.
- Model Persistence: Include code to save the model's
state_dictand code to load it for continued training or testing. - Testing/Inference: Implement a function that loads the model, generates coordinates for an arbitrary target resolution, performs prediction, and visualizes the result using matplotlib.
- Device Management: Ensure the model, input data, and target data are all moved to the same device (CPU or CUDA) to prevent errors.
Anti-Patterns
- Do not use Convolutional Neural Networks (CNNs); strictly use the requested MLP structure.
- Do not omit the positional encoding step.
- Do not hardcode image paths; use placeholders.
- Do not forget to handle variable transfer between CPU and GPU.
Triggers
- 用神经网络拟合图像坐标
- 使用位置编码重建图像
- 实现输入任意尺寸即可输出该尺寸的前述图像的代码
- 基于位置编码的图像回归代码
- 加载模型进行测试的test代码
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the 基于位置编码的图像坐标回归网络 skill do?
实现一个使用位置编码将像素坐标映射到像素值的PyTorch MLP网络,专门用于拟合灰度图像。支持任意分辨率输出、模型保存加载及设备管理。
How do I install the 基于位置编码的图像坐标回归网络 skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the 基于位置编码的图像坐标回归网络 skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…