Skip to content
Skill Authoring
Skill

/computer-vision

Implement computer vision tasks including image classification, object detection, segmentation, and pose estimation using PyTorch and TensorFlow

From plugin
useful-ai-prompts
309200 skills
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill computer-vision --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/computer-vision

Context preview

The summary Claude sees to decide when to auto-load this skill.

Implement computer vision tasks including image classification, object detection, segmentation, and pose estimation using PyTorch and TensorFlow

SKILL.md

computer-vision.SKILL.md
name: Computer Vision
description: Implement computer vision tasks including image classification, object detection, segmentation, and pose estimation using PyTorch and TensorFlow

Computer Vision

Overview

Computer vision enables machines to understand visual information from images and videos, powering applications like autonomous driving, medical imaging, and surveillance.

When to Use

  • Image classification and object recognition tasks
  • Object detection and localization in images
  • Semantic or instance segmentation projects
  • Pose estimation and human activity recognition
  • Face recognition and biometric systems
  • Medical imaging analysis and diagnostics

Computer Vision Tasks

  • **Image Classification**: Categorizing images into classes
  • **Object Detection**: Locating and classifying objects in images
  • **Semantic Segmentation**: Pixel-level classification
  • **Instance Segmentation**: Detecting individual object instances
  • **Pose Estimation**: Identifying human body joints
  • **Face Recognition**: Identifying individuals in images

Popular Architectures

  • **Classification**: ResNet, VGG, EfficientNet, Vision Transformer
  • **Detection**: YOLO, Faster R-CNN, SSD, RetinaNet
  • **Segmentation**: U-Net, DeepLab, Mask R-CNN
  • **Pose**: OpenPose, PoseNet, HRNet

Python Implementation

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image, ImageDraw
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, TensorDataset
from torchvision import transforms, models, datasets
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import cv2
from sklearn.metrics import accuracy_score, confusion_matrix
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')

print("=== 1. Image Classification CNN ===")

# Define image classification model
class ImageClassifierCNN(nn.Module):
    def __init__(self, num_classes=10):
        super().__init__()
        self.features = nn.Sequential(
            nn.Conv2d(3, 32, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.BatchNorm2d(32),
            nn.MaxPool2d(2, 2),

            nn.Conv2d(32, 64, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.BatchNorm2d(64),
            nn.MaxPool2d(2, 2),

            nn.Conv2d(64, 128, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.BatchNorm2d(128),
            nn.MaxPool2d(2, 2),
        )

        self.classifier = nn.Sequential(
            nn.Linear(128 * 4 * 4, 256),
            nn.ReLU(inplace=True),
            nn.Dropout(0.5),
            nn.Linear(256, num_classes)
        )

    def forward(self, x):
        x = self.features(x)
        x = x.view(x.size(0), -1)
        x = self.classifier(x)
        return x

model = ImageClassifierCNN(num_classes=10)
print(f"Model parameters: {sum(p.numel() for p in model.parameters()):,}")

# 2. Object Detection setup
print("\n=== 2. Object Detection Framework ===")

class ObjectDetector(nn.Module):
    def __init__(self):
        super().__init__()
        # Backbone
        self.backbone = nn.Sequential(
            nn.Conv2d(3, 32, 3, padding=1),
            nn.ReLU(),
            nn.MaxPool2d(2, 2),
            nn.Conv2d(32, 64, 3, padding=1),
            nn.ReLU(),
            nn.MaxPool2d(2, 2),
        )

        # Bounding box regression
        self.bbox_head = nn.Sequential(
            nn.Linear(64 * 8 * 8, 128),
            nn.ReLU(),
            nn.Linear(128, 4)  # x, y, w, h
        )

        # Class prediction
        self.class_head = nn.Sequential(
            nn.Linear(64 * 8 * 8, 128),
            nn.ReLU(),
            nn.Linear(128, 10)  # 10 classes
        )

    def forward(self, x):
        features = self.backbone(x)
        features_flat = features.view(features.size(0), -1)

        bboxes = self.bbox_head(features_flat)
        classes = self.class_head(features_flat)

        return bboxes, classes

detector = ObjectDetector()
print(f"Detector parameters: {sum(p.numel() for p in detector.parameters()):,}")

# 3. Semantic Segmentation
print("\n=== 3. Semantic Segmentation U-Net ===")

class UNet(nn.Module):
    def __init__(self, num_classes=5):
        super().__init__()
        # Encoder
        self.enc1 = self._conv_block(3, 32)
        self.pool1 = nn.MaxPool2d(2, 2)
        self.enc2 = self._conv_block(32, 64)
        self.pool2 = nn.MaxPool2d(2, 2)

        # Bottleneck
        self.bottleneck = self._conv_block(64, 128)

        # Decoder
        self.upconv2 = nn.ConvTranspose2d(128, 64, 2, stride=2)
        self.dec2 = self._conv_block(128, 64)
        self.upconv1 = nn.ConvTranspose2d(64, 32, 2, stride=2)
        self.dec1 = self._conv_block(64, 32)

        # Final output
        self.out = nn.Conv2d(32, num_classes, 1)

    def _conv_block(self, in_channels, out_channels):
        return nn.Sequential(
            nn.Conv2d(in_channels, out_channels, 3, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(out_channels, out_channels, 3, padding=1),
            nn.ReLU(inplace=True)
        )

    def forward(self, x):
        enc1 = self.enc1(x)
        enc2 = self.enc2(self.pool1(enc1))
        bottleneck = self.bottleneck(self.pool2(enc2))

        dec2 = self.dec2(torch.cat([self.upconv2(bottleneck), enc2], 1))
        dec1 = self.dec1(torch.cat([self.upconv1(dec2), enc1], 1))

        return self.out(dec1)

unet = UNet(num_classes=5)
print(f"U-Net parameters: {sum(p.numel() for p in unet.parameters()):,}")

# 4. Transfer Learning
print("\n=== 4. Transfer Learning with Pre-trained Models ===")

try:
    # Load pre-trained ResNet18
    pretrained_model = models.resnet18(pretrained=True)
    num_ftrs = pretrained_model.fc.in_features
    pretrained_model.fc = nn.Linear(num_ftrs, 10)

    print(f"Pre-trained ResNet18 adapted for 10 classes")
    print(f
Read more
Ships withuseful-ai-prompts

488 production-ready AI prompts, all following a standardized template with validated quality gates. Transform ChatGPT, Claude, and other AI assistants into expert consultants.

Get the whole plugin