LESSON 30分

ストーリー

田中VPoE
画像認識、画像生成、画像編集の技術を学んだ。ここでそれらを実際の業務に適用するケーススタディを見ていこう
あなた
技術は分かりましたが、実際にどう業務フローに組み込むかが知りたいです
田中VPoE
4つの業務シナリオを用意した。品質検査、商品画像の自動処理、マーケティング素材生成、そして名刺管理だ。それぞれ技術をどう組み合わせるか見ていこう
あなた
実践的なケーススタディですね。楽しみです

ケース1: 製品外観検査の自動化

背景

NetShop社のプライベートブランド商品で、出荷前の外観検査を目視で行っています。

現状の課題:
- 検査員3名で1日500個の外観検査
- 1個あたり平均2分(目視確認 + 記録)
- 見落とし率: 約3%(月15件のクレーム原因)
- 検査員の疲労による精度低下(午後は見落とし率5%に上昇)

AI導入後のフロー

import anthropic
import base64
from dataclasses import dataclass
from enum import Enum

class DefectLevel(Enum):
    NONE = "正常"
    MINOR = "軽微(出荷可)"
    MAJOR = "重大(出荷不可)"
    CRITICAL = "致命的(ライン停止)"

@dataclass
class InspectionResult:
    product_id: str
    defect_level: DefectLevel
    defects: list[str]
    confidence: float
    needs_human_review: bool
    image_path: str

def inspect_product(image_path: str, product_id: str) -> InspectionResult:
    """製品外観を自動検査"""
    client = anthropic.Anthropic()

    with open(image_path, "rb") as f:
        image_data = base64.b64encode(f.read()).decode()

    prompt = """この製品画像を検査してください。以下の基準で評価してください:

検査項目:
1. 傷・擦り傷の有無
2. 変色・色むらの有無
3. 形状の歪み・変形の有無
4. 印刷不良(ラベルのずれ、かすれ)の有無
5. 汚れ・付着物の有無

JSON形式で回答してください:
{
  "defect_level": "NONE/MINOR/MAJOR/CRITICAL",
  "defects": ["検出された問題のリスト"],
  "confidence": 0.0-1.0,
  "details": "詳細な所見"
}"""

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        messages=[{
            "role": "user",
            "content": [
                {"type": "image", "source": {"type": "base64", "media_type": "image/jpeg", "data": image_data}},
                {"type": "text", "text": prompt}
            ]
        }]
    )

    # レスポンスをパース(簡略化)
    import json
    result_data = json.loads(response.content[0].text)

    return InspectionResult(
        product_id=product_id,
        defect_level=DefectLevel[result_data["defect_level"]],
        defects=result_data["defects"],
        confidence=result_data["confidence"],
        needs_human_review=result_data["confidence"] < 0.9 or result_data["defect_level"] != "NONE",
        image_path=image_path
    )

運用設計

判定AI信頼度アクション
正常 + 高信頼度>= 0.95自動で出荷承認
正常 + 中信頼度0.8〜0.95検査員が確認
異常検出任意検査員が確認 + 記録
低信頼度< 0.8必ず人間が再検査

ケース2: 商品画像の自動処理パイプライン

背景

EC出品時の商品画像処理に時間がかかっています。

現状の課題:
- 月間10,000枚の商品画像を処理
- 1枚あたりの処理時間: 撮影後の編集に平均15分
- デザイナー3名がフルタイムで対応
- 背景統一、リサイズ、色補正、バリエーション生成

自動処理パイプライン

from dataclasses import dataclass
from pathlib import Path

@dataclass
class ImageProcessingConfig:
    target_size: tuple[int, int] = (1200, 1200)
    background_color: tuple[int, int, int] = (255, 255, 255)
    quality_threshold: float = 0.8
    generate_variants: bool = True
    variant_backgrounds: list[str] = None

    def __post_init__(self):
        if self.variant_backgrounds is None:
            self.variant_backgrounds = [
                "lifestyle setting, modern living room",
                "outdoor natural setting, garden",
                "minimalist studio, grey gradient background"
            ]

class ProductImagePipeline:
    """商品画像の自動処理パイプライン"""

    def __init__(self, config: ImageProcessingConfig):
        self.config = config

    def process(self, image_path: str, product_info: dict) -> dict:
        """1枚の商品画像を処理"""
        results = {"original": image_path, "processed": []}

        # Step 1: 品質チェック
        quality = self._check_quality(image_path)
        if quality["score"] < self.config.quality_threshold:
            return {"status": "rejected", "reason": quality["issues"]}

        # Step 2: 背景除去
        nobg_path = self._remove_background(image_path)
        results["no_background"] = nobg_path

        # Step 3: 白背景版の生成
        white_bg_path = self._apply_background(nobg_path, self.config.background_color)
        results["processed"].append({"type": "white_bg", "path": white_bg_path})

        # Step 4: リサイズ(ECサイト規格)
        resized_path = self._resize(white_bg_path, self.config.target_size)
        results["processed"].append({"type": "resized", "path": resized_path})

        # Step 5: バリエーション生成
        if self.config.generate_variants:
            for bg_prompt in self.config.variant_backgrounds:
                variant_path = self._generate_variant(nobg_path, bg_prompt, product_info)
                results["processed"].append({"type": "variant", "prompt": bg_prompt, "path": variant_path})

        # Step 6: 商品説明文の自動生成
        description = self._generate_description(image_path, product_info)
        results["description"] = description

        return {"status": "success", "results": results}

    def _check_quality(self, path: str) -> dict:
        """VLMで画像品質をチェック"""
        # 実装省略: Claude Visionで品質判定
        pass

    def _remove_background(self, path: str) -> str:
        """背景除去"""
        # 実装省略: rembgで背景除去
        pass

    def _apply_background(self, path: str, color: tuple) -> str:
        """背景色を適用"""
        # 実装省略
        pass

    def _resize(self, path: str, size: tuple) -> str:
        """リサイズ"""
        # 実装省略
        pass

    def _generate_variant(self, path: str, bg_prompt: str, info: dict) -> str:
        """背景バリエーションを生成"""
        # 実装省略: ControlNet + Stable Diffusion
        pass

    def _generate_description(self, path: str, info: dict) -> str:
        """商品説明文を自動生成"""
        # 実装省略: VLMで画像から説明文生成
        pass

ケース3: マーケティング素材の自動生成

ワークフロー

キャンペーン情報


[テンプレート選択] → ブランドガイドラインDB


[画像生成] → DALL-E 3 / Stable Diffusion


[テキストオーバーレイ] → Pillow / Canva API


[マルチサイズ展開] → Instagram / Twitter / バナー


[AB テストバリエーション] → 3〜5パターン生成


[レビュー・承認] → マーケティング担当者

サイズバリエーション自動生成

PLATFORM_SPECS = {
    "instagram_post": {"size": (1080, 1080), "format": "JPG"},
    "instagram_story": {"size": (1080, 1920), "format": "JPG"},
    "twitter_post": {"size": (1200, 675), "format": "JPG"},
    "facebook_ad": {"size": (1200, 628), "format": "JPG"},
    "web_banner_wide": {"size": (1920, 480), "format": "PNG"},
    "web_banner_square": {"size": (300, 300), "format": "PNG"},
}

def generate_multi_platform_assets(
    base_image_path: str,
    campaign_text: str,
    platforms: list[str] = None
) -> dict[str, str]:
    """複数プラットフォーム用の素材を一括生成"""
    if platforms is None:
        platforms = list(PLATFORM_SPECS.keys())

    results = {}
    for platform in platforms:
        spec = PLATFORM_SPECS[platform]
        output_path = f"output/{platform}.{spec['format'].lower()}"
        # リサイズ + テキストオーバーレイ + フォーマット変換
        results[platform] = output_path

    return results

ケース4: 名刺管理の自動化

処理フロー

名刺画像 → [前処理] → [OCR] → [NER] → [構造化] → CRMに登録


                         氏名、会社名、役職、
                         電話番号、メール、住所

ROIまとめ

ケース月間削減時間月間コスト削減追加効果
外観検査200時間60万円クレーム件数50%削減
商品画像500時間150万円出品リードタイム70%短縮
マーケティング100時間50万円AB テスト実施率3倍
名刺管理30時間9万円CRM登録率100%

まとめ

ケース使用技術効果
製品外観検査VLM + 画像認識見落とし率3%→0.5%
商品画像処理背景除去 + 生成AI処理時間15分→1分
マーケティング素材画像生成 + テンプレート素材制作時間80%削減
名刺管理OCR + NER手入力ゼロ、100%デジタル化

チェックリスト

  • 製品外観検査の自動化設計(信頼度ベースの判定フロー)を理解した
  • 商品画像の自動処理パイプラインを設計できる
  • マーケティング素材の自動生成ワークフローを把握した
  • 各ケースのROI試算方法を理解した

推定所要時間: 30分