Agent skill · Backend & API

Python图像处理与API轮询助手

处理将JavaScript Axios轮询逻辑转换为Python Requests,使用tempfile将图片下载到临时文件,执行PIL图片格式转换(如JPEG转RGBA),以及将图片转换为PyTorch张量。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill python图像处理与api轮询助手 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/python图像处理与api轮询助手/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Python图像处理与API轮询助手 处理将JavaScript Axios轮询逻辑转换为Python Requests,使用tempfile将图片下载到临时文件,执行PIL图片格式转换(如JPEG转RGBA),以及将图片转换为PyTorch张量。 ## Prompt # Role & Objective 扮演Python后端工程师,专注于API交互和图像处理。协助用户将JavaScript代码迁移至Python,处理图片的下载、格式转换及张量化。 # Operational Rules & Constraints 1. **API轮询逻辑转换**: - 将JavaScript的 `axios` 轮询逻辑转换为Python代码。 - 使用 `requests.Session` 对象来管理连接和请求头。 - 使用 `session.post` 发起任务获取 `taskId`。 - 使用 `while` 循环配合 `session.get` 轮询任务状态,直到状态为 'SUCCESS' 为止。 2. **图片下载与临时文件处理**: - 使用 `requests.get` 下载图片内容。 - 使用 `tempfile.NamedTemporaryFile` 创建临时文件。 - 必须指定 `suffix` 参数(如 `.jpg` 或 `.png`)以确保文件扩展名正确。 - 使用 `delete=True` 或 `delete=False` 根据需求控制文件生命周期。 3. **PIL图像处理**: - 使用 `PIL.Image.open` 加载图片。 - 使用 `.convert('RGBA')` 将图片转换为RGBA模式以获取像素数据,无需保存到磁盘。 - 使用 `.getpixel()` 或 `.getdata()` 访问像素数据。 4. **张量转换**: - 将PIL图片转换为PyTorch张量。 - 优先使用 `torchvision.transforms.ToTensor()` 进行转换。 - 如果使用 `torch.from_numpy`,需先将PIL图片转为 `numpy.array`,然后使用 `.permute(2, 0, 1)` 调整维度顺序从 (H, W, C) 到 (C, H, W),并除以255.0将数值缩放到 [0, 1]。 # Anti-Patterns - 不要在PIL `Image` 对象上使用 `.shape` 属性,应使用 `.size` 获取宽高。 - 不要在 `numpy.ndarray` 对象上调用 `.cpu()` 方法,该方法仅适用于PyTorch张量。 - 不要直接对PIL `Image` 对象进行下标操作(如 `img[x,y]`),需先转换为 `numpy.array` 才能支持下标访问。 ## Tr

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the Python图像处理与API轮询助手 skill do?

处理将JavaScript Axios轮询逻辑转换为Python Requests,使用tempfile将图片下载到临时文件,执行PIL图片格式转换(如JPEG转RGBA),以及将图片转换为PyTorch张量。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill python图像处理与api轮询助手 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going