---
title: "フィジカルAI研究室を作る Log#38 | ロボットアームの成否を Gemini が動画で判定、人は迷った回だけ見る"
slug: gemini-decision-video-judge-pi05-mecharm-runs
date: 2026-11-15
day: 520
meta_description: "Google の Gemini Decision 1 に、mechArm 270 で π0.5 を動かした録画を渡すと、人が確かめた19本中18本で成否が合った。外れた回は確信度か答えの食い違いで見分けられ、人が見る回を絞れた。費用は1日で約0.12ドル。"
tags: [フィジカルAI研究室, mechArm 270, π0.5, Physical Intelligence, Gemini Decision 1, Decisions API, ラベリング, 判定の画面]
series: "フィジカルAI研究室"
---

**Google の判断専用モデル Gemini Decision 1 に、小型ロボットアーム mechArm 270 で Physical Intelligence の π0.5 を実機で動かした録画をまるごと渡すと、人が確かめた19本のうち18本で、成功か失敗かの判定が人と合った。外れた1本も、確信度が高いのに「ブロックが箱の中にあるか」の値が低いという食い違いで見分けられた。** 実物のアームの録画での話です。1本あたりの判定は手元の Mac から送って中央値1.8秒、この回の試しすべてで約0.12ドルでした。

この回の試しで、次のことが変わりました。

- 人が録画を見る回を絞れる：人の判定がまだなかった推論の記録51本のうち、「人へ」に回ったのは3本だけだった。人がその3本を見たところ、成功か失敗かは3本とも AI と同じだった。前に人が25回を確かめたときは約40分かかっていた（LOG512）ので、見る本数が減ったぶん時間も減る見込み（この回は人の時間を測っていない）
- 人の付けた印の誤りが見つかった：推論のときに「成功」と入力していた1本は、録画のピントが合っておらず、アームも1チャンクも動いていなかった。AI の確信度が低かったので録画を見直し、人が「失敗」で付け直した
- 判定の画面の AI を、Claude から Gemini に切り替える依頼（依頼211）を出した。動画を見て選択肢ごとの確率と確信度で答えるので、「人へ」回す回を数字で分けられる

きっかけは、X で見かけた Erik Kokalj さんの[投稿](https://x.com/erik_kokalj)です。ごみの選別ラインの動画で、物を切り抜いて背景を消してから Gemini の Decisions API に「何の素材か」を聞き、Jev や OpenAI の同じ種類の API と正確さ・費用・速さを比べていました。同じ API は、Log#33（LOG497）で、アームのお手本56本の静止画を判定させたことがあります。そのときは「箱に入ったか」は全部当てられたものの、「今の Claude の判定と比べてどちらが良いか」と「推論の記録で使えるか」は確かめていませんでした。この回は、π0.5 を動かした推論の記録の録画を、動画のまま渡しました。

| やったこと | なぜ | 結果 |
|---|---|---|
| 推論の記録20本（人の判定あり）の録画を縮めて渡し、成否を聞いた（1版） | 動画で当たるか、確信度が誤りと結びつくかを見る | 19本中17本が合った。外れた2本は確信度0.41と0.43 |
| 外れた2本の録画を1コマずつ見た | なぜ外れたかを知る | 1本は人の印の誤り（アームが動いていない）。もう1本は、箱の横でつかんだままを「入れた」と読んだ |
| 最後のコマを高い解像度で足し、「最後もつかんだままか」を聞いた（2版） | 箱の横でつかんだままの見誤りを減らす | 19本中18本が合った。前の見誤りは直った |
| 人の判定がない51本に、2版で先回り判定を付けた | 人が見る回を絞る | 「人へ」は3本。人が確かめて、成否は3本とも合っていた |
| 判定の画面の AI を Gemini に切り替える依頼を出した（依頼211） | 次に推論の記録が増えたときに使う | 依頼箱で実行待ち |

数字は、記録（`runs/pi05_policy_verdicts_gemini_v1.csv`）と出力から数えた値です。決めた「人へ回す」決まりは、同じ19本の結果を見てから足したものなので、新しい記録で当たり続けるかはまだ確かめていません。

GPU を買うか借りるかの判断は、Runpod で実際に借りて学習させた費用をもとに、別のページにまとめています。この回で判定した推論も、その借り方で動かしたものです。

【バナー】gpu-buy-or-rent

【図解】LOG520_confidence_route.html


## 作業ログ ― 推論の記録の録画を Gemini Decision 1 に判定させ、人が見る回を絞るまで

ここから下は作業の記録です。コードと出力は全量で載せます。効果を書いた所のうち、数字で書いたものは測った値、「見込み」と書いたものはまだ確かめていない値です。

この回で何度も出てくる言葉を先に言い換えておきます。

- π0.5：[Physical Intelligence](https://www.pi.website/blog/pi05) が公開しているロボット用の AI。上カメラの画像と関節の角度を見て、次の動きを出す
- 推論の記録：π0.5 を実機で動かした1回分の記録。KIOXIA の `runs/pi05_policy/{名前}/` に入り、上カメラの録画 `recording/top.mp4` もここにある
- チャンク：π0.5 が一度に出す、動きのひとまとまり。「送ったチャンク 0」は、アームを1回も動かしていないこと
- 判定の表：推論の記録ごとに、成功か失敗か・だれが付けたかを書き足していく表（`runs/pi05_policy_verdicts_v1.csv`）。Log#36（LOG512）で作った
- 確信度：AI が自分の答えにどれだけ自信があるかを0〜1で表した値。この回は0.5未満を「人へ」回した
- 依頼箱：Claude Code への依頼をファイルで置いておく Mac のフォルダ。置くと見張り係が順に Claude Code に渡し、結果を書き戻す


### Gemini Decisions API は、選択肢に確率を付けて返すだけの API

[Gemini Decisions API](https://blog.google/innovation-and-ai/technology/developers-tools/gemini-decisions-api/) は、Google が2026年11月11日に出した API で、使うモデルは Gemini Decision 1（`gemini-decision-1`）です。文章を書かず、こちらが用意した問いに、選択肢ごとの確率と確信度を付けて返します。1回の問い合わせで、同じ動画や画像に最大1,000問まで聞けます。

| 言葉 | 意味 |
|---|---|
| `noul` | はい／いいえの問い。返る値は「はい」の確率 |
| `choice` | 選択肢から1つ選ぶ問い（2〜255択）。選んだもの・選択肢ごとの確率・確信度が返る |
| `score` | 段階で点を付ける問い |
| 入力 | 文章・画像・音声・動画・PDF。動画は base64 の中身ごとでも送れた |
| 料金 | 入力100万トークンあたり0.10ドル。出力は0（文章を書かないため） |

このプロジェクトでは、推論の記録に「成功したか」を先に付ける AI として使えるかを試しました。今の判定の画面の AI（依頼183 の `seed_verdicts.py --ai`）は Claude Sonnet 4.6 に6コマの静止画を見せ、文章で答えさせています。


## Gemini Decisions API を画像1枚で呼べるか確かめた

最初は、きっかけの投稿の画面写真（ごみの選別ラインの画像）1枚に3つの問いを投げて、呼び方と返り値の形を確かめました。画面写真をそのまま送ったので、文字やラベルが重なっていて、投稿のように物を切り抜いて背景を消すこともしていません。

API のキーは、AI Studio で作ったものを Mac の自分のフォルダ（`~/.config/p2m/gemini_api_key`）に置き、スクリプトが読むだけにしました。キーは git の外です。

### try_decisions.py（画像1枚での確かめ）

```python
"""Gemini Decisions API のお試し。使い方: GEMINI_API_KEY=... python3 try_decisions.py 画像"""
import base64, getpass, json, os, sys, time, urllib.request
import getpass, os, pathlib
KEY_FILE = pathlib.Path.home() / ".config" / "p2m" / "gemini_api_key"
key = os.environ.get("GEMINI_API_KEY", "")
if not (key and key.isascii()) and KEY_FILE.exists():
    key = KEY_FILE.read_text().strip()
if not (key and key.isascii()):
    key = getpass.getpass("Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: ").strip()
    KEY_FILE.parent.mkdir(parents=True, exist_ok=True)
    KEY_FILE.write_text(key); KEY_FILE.chmod(0o600)
img = sys.argv[1] if len(sys.argv) > 1 else "belt.png"
body = {
  "model": "gemini-decision-1",
  "input": [
    {"type": "image", "mime_type": "image/png", "resolution": "medium",
     "data": base64.b64encode(open(img, "rb").read()).decode()},
  ],
  "questions": {
    "conveyor_visible": {"type": "noul",
      "instructions": "Is there a conveyor belt carrying waste items in this image?"},
    "main_material": {"type": "choice",
      "instructions": "What is the material of the large green item in the center of the conveyor?",
      "criteria": {"PET": "PET plastic bottle", "film": "plastic film or bag",
                   "paper": "paper", "aluminum": "aluminum can", "other": "something else"}},
    "scene_clarity": {"type": "score",
      "instructions": "How clearly can the individual waste items be distinguished?",
      "criteria": ["unclear", "somewhat clear", "clear", "very clear"]},
  },
}
req = urllib.request.Request("https://generativelanguage.googleapis.com/v1beta/decisions",
  data=json.dumps(body).encode(), method="POST",
  headers={"x-goog-api-key": key, "Content-Type": "application/json"})
t = time.time()
with urllib.request.urlopen(req) as r: res = json.load(r)
print(f"往復 {1000*(time.time()-t):.0f} ms")
print(json.dumps(res, ensure_ascii=False, indent=2))
```

### try_decisions.py の出力

```
(base) shimazueiichi@shimadzueiichinoMacBook-Pro decisions_test % python3 try_decisions.py
Gemini の API キーを貼って Enter（画面には出ません）: 
往復 1888 ms
{
  "answers": {
    "main_material": {
      "confidence": 0.5206491290641175,
      "choice": "paper",
      "probabilities": {
        "PET": 0.10064465015132458,
        "aluminum": 0.03201212982675028,
        "paper": 0.5206491290641175,
        "other": 0.07395551960422951,
        "film": 0.27273857135357804
      },
      "type": "choice"
    },
    "scene_clarity": {
      "confidence": 0.3761143543766926,
      "score": 1.6765526988639552,
      "probabilities": {
        "0": 0.13496888807065086,
        "3": 0.2177036162789567,
        "1": 0.27121314127369983,
        "2": 0.3761143543766926
      },
      "legend": {
        "2": "clear",
        "0": "unclear",
        "3": "very clear",
        "1": "somewhat clear"
      },
      "type": "score"
    },
    "conveyor_visible": {
      "confidence": 0.9164608943746316,
      "noul": 0.9164608943746316,
      "type": "noul"
    }
  },
  "usage": {
    "total_tokens": 784,
    "total_input_tokens": 784,
    "input_tokens_by_modality": [
      {
        "modality": "text",
        "tokens": 240
      },
      {
        "modality": "image",
        "tokens": 544
      }
    ],
    "total_output_tokens": 0
  }
}
```

コンベアが写っているかは「はい」0.92 で正しく答えました。中央の緑の物は、見た目はフィルムに近いのに「紙」0.52 で、2番目がフィルム0.27でした。外れた答えには確信度0.52という低めの値が付いていて、迷いが数字に出ていました。往復は1.9秒、入力は784トークン（画像544・文章240）で、約0.00008ドルでした。


## 人の判定がある推論の記録20本を選び、録画を縮めた

人の判定と比べるために、判定の表から人が確かめた回を選びました。人が確定した回（human・human_only・human_fixed_ai）で録画がある回は35行あり、成功は2本しかなかったので、推論のときに入力した印（run_input）の成功から8本を足して、成功10本・失敗10本にしました。成功の8本は人が後から確かめた印ではない、という弱さがあります。

### 20本を選んだコード（Mac の作業用の shell で実行）

```python
cd $HOME/mnt/r2r2r-data/runs; python3 - <<'EOF'
import csv,os,glob,random
rows=list(csv.DictReader(open('pi05_policy_verdicts_v1.csv')))
last={}
for r in rows:
    if r['labeler'] in('human','human_only','human_fixed_ai','run_input') and r['outcome'] in('success','failure'):
        p=last.get(r['run_stem'])
        # human labels win over run_input; later rows win
        if p is None or r['labeler']!='run_input' or p['labeler']=='run_input': last[r['run_stem']]=r
def vid(s):
    v=glob.glob(f"pi05_policy/{s}/recording/top.mp4"); return v[0] if v else None
c=[(s,r) for s,r in last.items() if vid(s)]
S=[x for x in c if x[1]['outcome']=='success']; F=[x for x in c if x[1]['outcome']=='failure']
print(len(S),len(F))
random.seed(1)
hs=[x for x in S if x[1]['labeler']!='run_input']; rs=[x for x in S if x[1]['labeler']=='run_input']
pickS=hs+random.sample(rs,10-len(hs))
hf=[x for x in F if x[1]['labeler']!='run_input']
pickF=random.sample(hf,10)
out=os.path.expanduser('~/mnt/r2r2r-scripts/decisions_test/manifest.csv')
with open(out,'w',newline='') as f:
    w=csv.writer(f); w.writerow(['run_stem','human_outcome','pick','place','labeler'])
    for s,r in pickS+pickF: w.writerow([s,r['outcome'],r['pick'],r['place'],r['labeler']])
print(open(out).read())
EOF
```

出力は `43 30` でした（録画があって印のある回のうち、成功43・失敗30）。

元の録画は1920×1080・約10コマ／秒で、1本が最大116MB ありました。送れる大きさにするため、640px 幅・1秒2コマに縮めた写しを作りました（20本で6.2MB）。元の録画は読むだけです。失敗の1本（pi05_20261110_194015）は元の録画が壊れていて（`moov atom not found`）、19本で試しました。

### 録画を縮めたコマンド

```bash
cd $HOME/mnt/r2r2r-scripts/decisions_test; for s in $(tail -n +2 manifest.csv | cut -d, -f1); do [ -f videos/$s.mp4 ] || ffmpeg -nostdin -loglevel error -y -i $HOME/mnt/r2r2r-data/runs/pi05_policy/$s/recording/top.mp4 -vf "fps=2,scale=640:-2" -c:v libx264 -preset veryfast -crf 30 -an videos/$s.mp4; done; ls videos | wc -l; du -sh videos
```

最初は `-nostdin` を付けずに回し、ffmpeg が一覧の残りを読み込んでしまって途中の名前が崩れたので、付けて回し直しました。

### manifest.csv（照らし合わせる20本と人の判定）

照らし合わせのあとで1本の人の判定を付け直したので、下はその後の中身です（pi05_20261031_185246 の行。理由は後の節）。

```
run_stem,human_outcome,pick,place,labeler
pi05_20261110_112639,success,yes,yes,human_fixed_ai
pi05_20261114_182327,success,yes,yes,human
pi05_20261101_190347,success,yes,yes,run_input
pi05_20261114_180457,success,yes,yes,run_input
pi05_20261031_181946,success,yes,yes,run_input
pi05_20261106_184650,success,yes,yes,run_input
pi05_20261031_185246,failure,no,not_applicable,human_only
pi05_20261113_193254,success,yes,yes,run_input
pi05_20261111_101720,success,yes,yes,run_input
pi05_20261111_160851,success,yes,yes,run_input
pi05_20261111_161402,failure,yes,no,human_only
pi05_20261111_101102,failure,yes,no,human_only
pi05_20261106_184312,failure,no,unknown,human_only
pi05_20261031_183426,failure,yes,no,human_only
pi05_20261111_102043,failure,yes,no,human_only
pi05_20261030_185133,failure,no,not_applicable,human_only
pi05_20261110_114106,failure,yes,no,human
pi05_20261111_101217,failure,yes,no,human_only
pi05_20261110_194015,failure,no,not_applicable,human
pi05_20261111_101557,failure,yes,no,human_only
```

【画像】LOG520_01_top_camera_scene.jpg 上カメラの録画の最初のコマ。黒いカッターマットの上に、左に赤いブロック、中央にグリッパーを開いた mechArm 270、右に白い箱がある


## 1版：録画だけを渡し、19本中17本が人の判定と合った

問いは3つにしました。「つかんで持ち上げたか」「最後に箱の中にあるか」と、結果を「成功」「つかめず」「つかんだが置けず」から選ぶ問いです。成功以外を選んだら失敗として、人の判定と比べます。

### judge_videos.py（1版）

```python
"""π0.5 の推論の動画を Gemini Decisions API に判定させ、人の判定と照らし合わせる（お試し）。
使い方: cd ~/r2r2r-scripts/decisions_test && python3 judge_videos.py
入力: manifest.csv（人の判定）と videos/{run_stem}.mp4（640px・2fps に縮めた写し）
出力: results.jsonl（1本ずつの生の答え）と summary.txt（合った割合）
"""
import base64, csv, getpass, json, os, time, urllib.error, urllib.request

import getpass, os, pathlib
KEY_FILE = pathlib.Path.home() / ".config" / "p2m" / "gemini_api_key"
key = os.environ.get("GEMINI_API_KEY", "")
if not (key and key.isascii()) and KEY_FILE.exists():
    key = KEY_FILE.read_text().strip()
if not (key and key.isascii()):
    key = getpass.getpass("Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: ").strip()
    KEY_FILE.parent.mkdir(parents=True, exist_ok=True)
    KEY_FILE.write_text(key); KEY_FILE.chmod(0o600)

QUESTIONS = {
    "grasped": {"type": "noul",
        "instructions": "This is a top-down video of a robot arm. At any point in the video, does the gripper grasp the red block and lift it off the mat?"},
    "in_box_at_end": {"type": "noul",
        "instructions": "At the end of the video, is the red block inside the white box?"},
    "outcome": {"type": "choice",
        "instructions": "The robot's task is: put the red block in the white box. What best describes the result of this attempt?",
        "criteria": {
            "success": "The red block ends up inside the white box.",
            "failed_grasp": "The robot never manages to grasp and lift the red block.",
            "grasped_not_placed": "The robot lifts the red block but it does not end up inside the white box.",
        }},
}

def ask(path):
    body = {"model": "gemini-decision-1",
            "input": [{"type": "video", "mime_type": "video/mp4", "resolution": "low",
                       "data": base64.b64encode(open(path, "rb").read()).decode()}],
            "questions": QUESTIONS}
    req = urllib.request.Request("https://generativelanguage.googleapis.com/v1beta/decisions",
        data=json.dumps(body).encode(), method="POST",
        headers={"x-goog-api-key": key, "Content-Type": "application/json"})
    t = time.time()
    with urllib.request.urlopen(req, timeout=180) as r:
        res = json.load(r)
    return res, round(1000 * (time.time() - t))

rows = list(csv.DictReader(open("manifest.csv")))
out = open("results.jsonl", "a")
lines = []
for i, row in enumerate(rows, 1):
    s = row["run_stem"]
    path = f"videos/{s}.mp4"
    if not os.path.exists(path):
        print(f"[{i}] {s}: 動画なし（飛ばす）"); continue
    try:
        res, ms = ask(path)
    except urllib.error.HTTPError as e:
        msg = e.read().decode()[:500]
        print(f"[{i}] {s}: HTTP {e.code} {msg}")
        out.write(json.dumps({"run_stem": s, "error": e.code, "msg": msg}, ensure_ascii=False) + "\n"); out.flush()
        if i == 1: break  # 1本目で失敗したら形が違う。止める
        continue
    a = res["answers"]
    ai = a["outcome"]["choice"]
    ai_ok = "success" if ai == "success" else "failure"
    rec = {"run_stem": s, "human": row["human_outcome"], "human_pick": row["pick"], "human_place": row["place"],
           "ai_outcome": ai, "ai_conf": round(a["outcome"]["confidence"], 3),
           "p_grasped": round(a["grasped"]["noul"], 3), "p_in_box": round(a["in_box_at_end"]["noul"], 3),
           "match": ai_ok == row["human_outcome"], "ms": ms, "tokens": res["usage"]["total_input_tokens"], "raw": res}
    out.write(json.dumps(rec, ensure_ascii=False) + "\n"); out.flush()
    line = f"[{i}] {s} 人:{row['human_outcome']:7} AI:{ai:18} 確信{rec['ai_conf']:.2f} 箱の中{rec['p_in_box']:.2f} {'○' if rec['match'] else '×'} {ms}ms {rec['tokens']}tok"
    print(line); lines.append((rec, line))

if lines:
    n = len(lines); m = sum(r["match"] for r, _ in lines)
    toks = sum(r["tokens"] for r, _ in lines)
    summary = [f"合った割合: {m}/{n}", f"入力トークン合計: {toks}（約 ${toks/1e6*0.10:.4f}）", ""] + [l for _, l in lines]
    open("summary.txt", "w").write("\n".join(summary) + "\n")
    print("\n".join(summary[:2]))
```

### judge_videos.py の出力（1回目）

```
(base) shimazueiichi@shimadzueiichinoMacBook-Pro decisions_test % cd ~/r2r2r-scripts/decisions_test && python3 judge_videos.py
Gemini の API キーを貼って Enter（画面には出ません）: 
[1] pi05_20261110_112639 人:success AI:success            確信0.76 箱の中0.88 ○ 1573ms 8750tok
[2] pi05_20261114_182327 人:success AI:success            確信0.78 箱の中0.77 ○ 2097ms 13203tok
[3] pi05_20261101_190347 人:success AI:success            確信0.91 箱の中0.91 ○ 3514ms 17656tok
[4] pi05_20261114_180457 人:success AI:success            確信0.97 箱の中0.90 ○ 1462ms 6560tok
[5] pi05_20261031_181946 人:success AI:success            確信0.97 箱の中0.92 ○ 1787ms 21452tok
[6] pi05_20261106_184650 人:success AI:success            確信0.95 箱の中0.90 ○ 1338ms 6852tok
[7] pi05_20261031_185246 人:success AI:failed_grasp       確信0.41 箱の中0.38 × 1018ms 4151tok
[8] pi05_20261113_193254 人:success AI:success            確信0.97 箱の中0.93 ○ 3271ms 9918tok
[9] pi05_20261111_101720 人:success AI:success            確信0.89 箱の中0.84 ○ 1463ms 6414tok
[10] pi05_20261111_160851 人:success AI:success            確信0.94 箱の中0.88 ○ 3172ms 18970tok
[11] pi05_20261111_161402 人:failure AI:grasped_not_placed 確信0.55 箱の中0.17 ○ 2022ms 13422tok
[12] pi05_20261111_101102 人:failure AI:grasped_not_placed 確信0.61 箱の中0.14 ○ 1882ms 4005tok
[13] pi05_20261106_184312 人:failure AI:grasped_not_placed 確信0.56 箱の中0.14 ○ 2205ms 4662tok
[14] pi05_20261031_183426 人:failure AI:grasped_not_placed 確信0.72 箱の中0.12 ○ 10767ms 21014tok
[15] pi05_20261111_102043 人:failure AI:success            確信0.43 箱の中0.44 × 893ms 4735tok
[16] pi05_20261030_185133 人:failure AI:grasped_not_placed 確信0.67 箱の中0.15 ○ 12711ms 47148tok
[17] pi05_20261110_114106 人:failure AI:grasped_not_placed 確信0.63 箱の中0.16 ○ 1412ms 10502tok
[18] pi05_20261111_101217 人:failure AI:failed_grasp       確信0.53 箱の中0.11 ○ 1424ms 3932tok
[19] pi05_20261110_194015: 動画なし（飛ばす）
[20] pi05_20261111_101557 人:failure AI:grasped_not_placed 確信0.43 箱の中0.32 ○ 2265ms 4224tok
合った割合: 17/19
入力トークン合計: 227570（約 $0.0228）
```

### judge_videos.py の出力（2回目・同じ19本をもう一度）

キーの保存の仕組みを足したあとに同じ19本でもう一度回しました。答えは19本すべて同じで、確信度の揺れは最大0.06（「箱の中」0.88→0.82 など）でした。0.5の境目をまたいだ回はありませんでした。

```
(base) shimazueiichi@shimadzueiichinoMacBook-Pro decisions_test % cd ~/r2r2r-scripts/decisions_test && python3 judge_videos.py
Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: 
[1] pi05_20261110_112639 人:success AI:success            確信0.76 箱の中0.82 ○ 1201ms 8750tok
[2] pi05_20261114_182327 人:success AI:success            確信0.78 箱の中0.77 ○ 2810ms 13203tok
[3] pi05_20261101_190347 人:success AI:success            確信0.91 箱の中0.91 ○ 1922ms 17656tok
[4] pi05_20261114_180457 人:success AI:success            確信0.97 箱の中0.95 ○ 969ms 6560tok
[5] pi05_20261031_181946 人:success AI:success            確信0.95 箱の中0.92 ○ 1664ms 21452tok
[6] pi05_20261106_184650 人:success AI:success            確信0.95 箱の中0.90 ○ 1299ms 6852tok
[7] pi05_20261031_185246 人:success AI:failed_grasp       確信0.41 箱の中0.38 × 561ms 4151tok
[8] pi05_20261113_193254 人:success AI:success            確信0.97 箱の中0.93 ○ 1457ms 9918tok
[9] pi05_20261111_101720 人:success AI:success            確信0.89 箱の中0.84 ○ 1089ms 6414tok
[10] pi05_20261111_160851 人:success AI:success            確信0.94 箱の中0.88 ○ 2144ms 18970tok
[11] pi05_20261111_161402 人:failure AI:grasped_not_placed 確信0.55 箱の中0.17 ○ 3010ms 13422tok
[12] pi05_20261111_101102 人:failure AI:grasped_not_placed 確信0.61 箱の中0.14 ○ 1360ms 4005tok
[13] pi05_20261106_184312 人:failure AI:grasped_not_placed 確信0.56 箱の中0.14 ○ 1098ms 4662tok
[14] pi05_20261031_183426 人:failure AI:grasped_not_placed 確信0.72 箱の中0.12 ○ 1284ms 21014tok
[15] pi05_20261111_102043 人:failure AI:success            確信0.43 箱の中0.44 × 822ms 4735tok
[16] pi05_20261030_185133 人:failure AI:grasped_not_placed 確信0.67 箱の中0.15 ○ 9410ms 47148tok
[17] pi05_20261110_114106 人:failure AI:grasped_not_placed 確信0.63 箱の中0.16 ○ 1742ms 10502tok
[18] pi05_20261111_101217 人:failure AI:failed_grasp       確信0.53 箱の中0.11 ○ 911ms 3932tok
[19] pi05_20261110_194015: 動画なし（飛ばす）
[20] pi05_20261111_101557 人:failure AI:grasped_not_placed 確信0.43 箱の中0.32 ○ 1205ms 4224tok
合った割合: 17/19
入力トークン合計: 227570（約 $0.0228）
```

外れた2本は、どちらも確信度が0.5を下回っていました（0.41と0.43）。確信度0.5以上の16本はすべて人の判定と合っていたので、「0.5未満だけ人が見る」と決めれば、人が見るのは19本中3本で済み、誤りは全部そこに入ります。失敗の判定は確信度が0.5〜0.7台と低めで、成功の判定（0.9前後が多い）と差がありました。


## 外れた2本の録画を見た：1本は人の印の誤り、1本は箱の横でつかんだまま

外れた2本の縮めた録画から16コマを並べた画像を作って見ました。

### 16コマを並べた画像を作ったコマンド

```bash
cd $HOME/mnt/r2r2r-scripts/decisions_test; mkdir -p peek; for s in pi05_20261031_185246 pi05_20261111_102043; do d=$(ffprobe -v error -show_entries format=duration -of csv=p=0 videos/$s.mp4); n=$(ffprobe -v error -count_frames -select_streams v -show_entries stream=nb_read_frames -of csv=p=0 videos/$s.mp4); echo "$s dur=$d frames=$n"; step=$(( (n+15)/16 )); ffmpeg -nostdin -loglevel error -y -i videos/$s.mp4 -vf "select='not(mod(n\,$step))',scale=480:-2,drawtext=text='%{pts\:hms}':x=8:y=8:fontsize=22:fontcolor=yellow:box=1:boxcolor=black,tile=4x4" -frames:v 1 peek/${s}_sheet.jpg 2>&1 | tail -2; done; ls -la peek
```

```
pi05_20261031_185246 dur=53.000000 frames=106
pi05_20261111_102043 dur=60.500000 frames=121
```

### pi05_20261031_185246：人は成功、AI は「つかめず」（確信度0.41）

【画像】LOG520_02_185246_contact_sheet.jpg 推論の記録 pi05_20261031_185246 の録画から16コマを並べた画像。53秒の間ずっとピントが合わず、アームはほとんど動いていない

録画は最初から最後までピントが合っておらず、アームも53秒の間ほとんど動いていません。記録の JSON を見ると、π0.5 に送ったチャンクの履歴（`history_left`）が空で、終わり方は手で止めたことを示す `q` でした。

```
== pi05_20261031_185246
{'frames': 531, 'elapsed_sec': 60.143, 'effective_fps': 8.829, 'status': 'ok'}
{'end_reason': 'q', 'result': 'completed', 'outcome': 'success', 'rewinds': 0, 'corrections': 0, 'prompt': None}
chunks 0
2026-10-31T18:53:55.872352,pi05_20261031_185246,yes,yes,success,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
```

成功の印は、推論を終えたときに入力した値（run_input）がそのまま写されたもので、人が録画を見て確かめた印ではありませんでした。**外れたのは AI ではなく、人の印のほうだった可能性が高い。** 録画を見て、人が判定の画面で「失敗（つかめなかった・そこまで行かなかった）」に付け直しました（下の判定の表の行）。

### pi05_20261111_102043：人は失敗、AI は成功（確信度0.43）

【画像】LOG520_03_102043_contact_sheet.jpg 推論の記録 pi05_20261111_102043 の録画から16コマを並べた画像。20秒ごろに赤いブロックをつかみ、最後は白い箱のすぐ横までつかんだまま運んでいる

【画像】LOG520_04_102043_last_frame.jpg pi05_20261111_102043 の元の録画の最後のコマ。グリッパーは赤いブロックをつかんだまま、白い箱の左横で止まっている

20秒ごろに赤いブロックをつかみ、最後は箱のすぐ横まで運んでいますが、放していません。元の録画の最後のコマでも、つかんだまま箱の左にありました。AI は「箱の横でつかんでいる」状態を「入れた」と読んだようです。ただ、このときも「箱の中」の確率は0.44で、迷いは数字に出ていました。

### 外れた2本の記録の中身を見たコマンドと出力

```bash
cd $HOME/mnt/r2r2r-data/runs/pi05_policy; for s in pi05_20261031_185246 pi05_20261111_102043; do echo "== $s"; python3 -c "
import json;m=json.load(open('$s/recording/top_meta.json'));print({k:m.get(k) for k in ['frames','elapsed_sec','effective_fps','status']})
j=json.load(open('$s/$s.json'));print({k:j.get(k) for k in ['end_reason','result','outcome','rewinds','corrections','prompt']}); print('chunks',len(j.get('history_left',[])))"; grep "$s" ../pi05_policy_verdicts_v1.csv; done
```

```
== pi05_20261031_185246
{'frames': 531, 'elapsed_sec': 60.143, 'effective_fps': 8.829, 'status': 'ok'}
{'end_reason': 'q', 'result': 'completed', 'outcome': 'success', 'rewinds': 0, 'corrections': 0, 'prompt': None}
chunks 0
2026-10-31T18:53:55.872352,pi05_20261031_185246,yes,yes,success,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
== pi05_20261111_102043
{'frames': 607, 'elapsed_sec': 69.016, 'effective_fps': 8.795, 'status': 'ok'}
{'end_reason': 'h', 'result': 'completed', 'outcome': 'failure', 'rewinds': 0, 'corrections': 0, 'prompt': None}
chunks 9
2026-11-11T10:22:02.476686,pi05_20261111_102043,no,no,failure,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-15T08:25:45+09:00,pi05_20261111_102043,no,no,failure,human_only,,,top.mp4,
2026-11-15T08:30:48+09:00,pi05_20261111_102043,yes,no,failure,human_only,,,top.mp4,
```

人の印の誤りを除けば、1版は19本中18本が合っていたことになります。


## 2版：最後のコマを足し、「最後もつかんだままか」を聞いた

箱の横でつかんだままの見誤りを減らすため、3つ直しました。

- 縮めた動画に加えて、最後のコマを1280px 幅の jpg で一緒に送る（`resolution: high`）
- 「最後のコマで、ブロックはまだ爪の間にあるか」を聞く問いを足す
- 結果の選択肢に「アームがほとんど動かない／映像がぼやけて見えない」を足す

ねらい：箱の横でつかんだままの回を「成功」と読ませない。
変わったこと：送るものが動画1本から動画＋高解像度の最後のコマになり、問いが3つから4つになった。
変わった結果：19本で試すと、前の見誤り（102043）が「つかんだが置けず」に直り、人の印の誤りだった185246 は「人へ」に回った（下の出力）。

### 最後のコマを切り出したコマンド

```bash
cd $HOME/mnt/r2r2r-scripts/decisions_test; mkdir -p last_frames; end=$((SECONDS+160)); for s in $( (tail -n +2 manifest_unlabeled.csv; tail -n +2 manifest.csv) | cut -d, -f1 | sort -u); do [ $SECONDS -gt $end ] && break; [ -f last_frames/$s.jpg ] || ffmpeg -nostdin -loglevel error -y -sseof -0.5 -i $HOME/mnt/r2r2r-data/runs/pi05_policy/$s/recording/top.mp4 -frames:v 1 -vf scale=1280:-2 -q:v 4 last_frames/$s.jpg 2>/dev/null; done; ls last_frames | wc -l; du -sh last_frames
```

```
63
5.2M	last_frames
```

この切り出しは、録画の本当の最後から0.5秒手前のコマです。あとで判定の画面のコード（`seed_verdicts.py`）を読み直して分かったのですが、録画の終わりには、人がブロックを箱から出している区間（`top_frame_log.csv` の mode が wait か home）が入ることがあります。今の画面の AI は、その区間を除いた「π0.5 が動いていた区間の終わり」までからコマを選んでいます。2版はそこを除いていなかったので、依頼211 では除く形にしました。

### judge_v2.py（2版）

```python
"""π0.5 の推論の記録を Gemini Decisions API で先回り判定する（2版）。
1版からの変更: 最後の1コマを高い解像度の画像として動画と一緒に送り、「最後もつかんだままか」を聞く。
使い方:
  python3 judge_v2.py manifest.csv            … 人の判定がある19本で、直したことが効くか確かめる
  python3 judge_v2.py manifest_unlabeled.csv  … 人の判定がまだない記録に先回り判定を付ける
出力: v2_{manifestの名前}.csv（1本1行）と v2_{manifestの名前}.jsonl（生の答え）
判定の表（pi05_policy_verdicts_v1.csv）には書かない。
"""
import base64, csv, getpass, json, os, pathlib, sys, time, urllib.error, urllib.request

KEY_FILE = pathlib.Path.home() / ".config" / "p2m" / "gemini_api_key"
key = os.environ.get("GEMINI_API_KEY", "")
if not (key and key.isascii()) and KEY_FILE.exists():
    key = KEY_FILE.read_text().strip()
if not (key and key.isascii()):
    key = getpass.getpass("Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: ").strip()
    KEY_FILE.parent.mkdir(parents=True, exist_ok=True)
    KEY_FILE.write_text(key); KEY_FILE.chmod(0o600)

THRESHOLD = 0.5  # これ未満は人が見る

QUESTIONS = {
    "grasped": {"type": "noul",
        "instructions": "In the video, does the gripper grasp the red block and lift it off the mat at any point?"},
    "holding_at_end": {"type": "noul",
        "instructions": "Look at the final frame image. Is the red block still held between the gripper fingers?"},
    "in_box_at_end": {"type": "noul",
        "instructions": "Look at the final frame image. Is the red block resting inside the white box (not held by the gripper, not beside the box)?"},
    "outcome": {"type": "choice",
        "instructions": "The robot's task is: put the red block in the white box. Judge only by what is visible at the end. What best describes the result?",
        "criteria": {
            "success": "At the end the red block is inside the white box and the gripper has released it.",
            "failed_grasp": "The robot never grasps and lifts the red block.",
            "grasped_not_placed": "The robot lifts the red block, but at the end it is not inside the white box (still held, dropped, or beside the box).",
            "no_motion": "The robot arm barely moves, or the video is too blurry to see what happens.",
        }},
}

def b64(p): return base64.b64encode(open(p, "rb").read()).decode()

def ask(stem):
    body = {"model": "gemini-decision-1",
            "input": [
                {"type": "text", "text": "Top-down camera. First: the whole attempt as a video. Second: the final frame at high resolution."},
                {"type": "video", "mime_type": "video/mp4", "resolution": "low", "data": b64(f"videos/{stem}.mp4")},
                {"type": "image", "mime_type": "image/jpeg", "resolution": "high", "data": b64(f"last_frames/{stem}.jpg")},
            ],
            "questions": QUESTIONS}
    req = urllib.request.Request("https://generativelanguage.googleapis.com/v1beta/decisions",
        data=json.dumps(body).encode(), method="POST",
        headers={"x-goog-api-key": key, "Content-Type": "application/json"})
    t = time.time()
    with urllib.request.urlopen(req, timeout=180) as r:
        res = json.load(r)
    return res, round(1000 * (time.time() - t))

manifest = sys.argv[1] if len(sys.argv) > 1 else "manifest.csv"
name = pathlib.Path(manifest).stem
rows = list(csv.DictReader(open(manifest)))
has_human = "human_outcome" in rows[0]
raw = open(f"v2_{name}.jsonl", "w")
out_rows = []
for i, row in enumerate(rows, 1):
    s = row["run_stem"]
    if not (os.path.exists(f"videos/{s}.mp4") and os.path.exists(f"last_frames/{s}.jpg")):
        print(f"[{i}] {s}: 動画か最後のコマがない（飛ばす）"); continue
    try:
        res, ms = ask(s)
    except urllib.error.HTTPError as e:
        msg = e.read().decode()[:500]
        print(f"[{i}] {s}: HTTP {e.code} {msg}")
        if i == 1: break
        continue
    a = res["answers"]
    ai = a["outcome"]["choice"]; conf = a["outcome"]["confidence"]
    rec = {"run_stem": s, "ai_outcome": ai, "ai_success_or_failure": "success" if ai == "success" else "failure",
           "ai_conf": round(conf, 3), "route": "auto" if conf >= THRESHOLD else "human",
           "p_grasped": round(a["grasped"]["noul"], 3), "p_holding_at_end": round(a["holding_at_end"]["noul"], 3),
           "p_in_box_at_end": round(a["in_box_at_end"]["noul"], 3), "ms": ms, "tokens": res["usage"]["total_input_tokens"]}
    if has_human:
        rec["human"] = row["human_outcome"]; rec["match"] = rec["ai_success_or_failure"] == row["human_outcome"]
    else:
        rec["previous_label"] = f"{row['latest_labeler']}:{row['latest_outcome']}"
    raw.write(json.dumps({**rec, "raw": res}, ensure_ascii=False) + "\n"); raw.flush()
    out_rows.append(rec)
    tail = (" " + ("○" if rec["match"] else "×") + f" 人:{rec['human']}") if has_human else f" 前の印:{rec['previous_label']}"
    print(f"[{i}] {s} AI:{ai:18} 確信{conf:.2f} 持ったまま{rec['p_holding_at_end']:.2f} 箱の中{rec['p_in_box_at_end']:.2f} → {'自動' if rec['route']=='auto' else '人へ'}{tail}")

if out_rows:
    with open(f"v2_{name}.csv", "w", newline="") as f:
        w = csv.DictWriter(f, fieldnames=list(out_rows[0].keys())); w.writeheader(); w.writerows(out_rows)
    n = len(out_rows); toks = sum(r["tokens"] for r in out_rows)
    auto = [r for r in out_rows if r["route"] == "auto"]
    print(f"\n本数 {n} / 自動 {len(auto)} / 人へ {n-len(auto)} / 入力トークン {toks}（約 ${toks/1e6*0.10:.4f}）")
    if has_human:
        print(f"合った割合: {sum(r['match'] for r in out_rows)}/{n}　自動のうち合った: {sum(r['match'] for r in auto)}/{len(auto)}")
```

### judge_v2.py の出力（人の判定がある19本）

```
(base) shimazueiichi@shimadzueiichinoMacBook-Pro decisions_test % cd ~/r2r2r-scripts/decisions_test && python3 judge_v2.py manifest.csv && python3 judge_v2.py manifest_unlabeled.csv
Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: 
[1] pi05_20261110_112639 AI:success            確信0.62 持ったまま0.29 箱の中0.36 → 自動 ○ 人:success
[2] pi05_20261114_182327 AI:success            確信0.75 持ったまま0.12 箱の中0.70 → 自動 ○ 人:success
[3] pi05_20261101_190347 AI:success            確信0.97 持ったまま0.06 箱の中0.93 → 自動 ○ 人:success
[4] pi05_20261114_180457 AI:success            確信0.98 持ったまま0.05 箱の中0.93 → 自動 ○ 人:success
[5] pi05_20261031_181946 AI:success            確信0.97 持ったまま0.04 箱の中0.92 → 自動 ○ 人:success
[6] pi05_20261106_184650 AI:success            確信0.88 持ったまま0.12 箱の中0.82 → 自動 ○ 人:success
[7] pi05_20261031_185246 AI:failed_grasp       確信0.32 持ったまま0.37 箱の中0.32 → 人へ ○ 人:failure
[8] pi05_20261113_193254 AI:success            確信0.97 持ったまま0.09 箱の中0.92 → 自動 ○ 人:success
[9] pi05_20261111_101720 AI:success            確信0.97 持ったまま0.05 箱の中0.92 → 自動 ○ 人:success
[10] pi05_20261111_160851 AI:success            確信0.97 持ったまま0.06 箱の中0.94 → 自動 ○ 人:success
[11] pi05_20261111_161402 AI:grasped_not_placed 確信0.65 持ったまま0.18 箱の中0.14 → 自動 ○ 人:failure
[12] pi05_20261111_101102 AI:grasped_not_placed 確信0.68 持ったまま0.09 箱の中0.10 → 自動 ○ 人:failure
[13] pi05_20261106_184312 AI:success            確信0.86 持ったまま0.11 箱の中0.44 → 自動 × 人:failure
[14] pi05_20261031_183426 AI:grasped_not_placed 確信0.56 持ったまま0.09 箱の中0.09 → 自動 ○ 人:failure
[15] pi05_20261111_102043 AI:grasped_not_placed 確信0.61 持ったまま0.11 箱の中0.18 → 自動 ○ 人:failure
[16] pi05_20261030_185133 AI:grasped_not_placed 確信0.71 持ったまま0.08 箱の中0.07 → 自動 ○ 人:failure
[17] pi05_20261110_114106 AI:grasped_not_placed 確信0.87 持ったまま0.06 箱の中0.10 → 自動 ○ 人:failure
[18] pi05_20261111_101217 AI:failed_grasp       確信0.69 持ったまま0.10 箱の中0.09 → 自動 ○ 人:failure
[19] pi05_20261110_194015: 動画か最後のコマがない（飛ばす）
[20] pi05_20261111_101557 AI:grasped_not_placed 確信0.64 持ったまま0.17 箱の中0.10 → 自動 ○ 人:failure

本数 19 / 自動 18 / 人へ 1 / 入力トークン 250978（約 $0.0251）
合った割合: 18/19　自動のうち合った: 17/18
```

19本中18本が合いました。新しく外れたのは pi05_20261106_184312 の1本で、AI は確信度0.86で「成功」と答えたのに、「箱の中にあるか」は0.44でした。答えと「箱の中」の値が食い違っています。そこで「成功と答えたのに、箱の中が0.5未満なら人へ回す」と決めると、この19本では次のようになります。

| 決まり | 自動で決まった本数 | そのうち人と合った | 人へ回った本数 |
|---|---|---|---|
| 確信度0.5未満を人へ（2版の出力のまま） | 18 | 17 | 1 |
| 上に、成功なのに箱の中0.5未満を人へを足す | 16 | 16 | 3（184312・185246・112639） |

112639 は人も成功としていた回で、人へ回ったのは空振りです。この決まりは、同じ19本の結果を見てから足したものです。新しい記録で同じように効くかは、まだ確かめていません。


## 人の判定がない51本に先回り判定を付け、人が見たのは3本

判定の表で、人が確かめた行がない回は127本あり、そのうち録画があるのは53本、壊れていた2本を除いて51本でした。残りの74本は録画がないので、この回は対象にしていません。51本の多く（40本）は、推論のときに入力した「成功」の印だけが付いている回です。

### 51本を選んだコード

```python
cd $HOME/mnt/r2r2r-data/runs; python3 - <<'EOF'
import csv,os,collections,subprocess
rows=list(csv.DictReader(open('pi05_policy_verdicts_v1.csv')))
H={'human','human_only','human_fixed_ai'}
by=collections.defaultdict(list)
for r in rows: by[r['run_stem']].append(r)
nohuman=[s for s,rs in by.items() if not any(r['labeler'] in H for r in rs)]
withv=[s for s in nohuman if os.path.exists(f'pi05_policy/{s}/recording/top.mp4')]
print('runs',len(by),'no human',len(nohuman),'with video',len(withv))
c=collections.Counter(by[s][-1]['labeler']+':'+by[s][-1]['outcome'] for s in withv); print(c)
bad=[]
for s in withv:
    p=subprocess.run(['ffprobe','-v','error','-show_entries','format=duration','-of','csv=p=0',f'pi05_policy/{s}/recording/top.mp4'],capture_output=True,text=True)
    if p.returncode or not p.stdout.strip(): bad.append(s)
print('broken',len(bad),bad[:5])
good=[s for s in withv if s not in bad]
with open(os.path.expanduser('~/mnt/r2r2r-scripts/decisions_test/manifest_unlabeled.csv'),'w',newline='') as f:
    w=csv.writer(f); w.writerow(['run_stem','latest_labeler','latest_outcome'])
    for s in sorted(good): w.writerow([s,by[s][-1]['labeler'],by[s][-1]['outcome']])
print('targets',len(good))
EOF
```

```
runs 176 no human 127 with video 53
Counter({'run_input:success': 40, 'rule:not_applicable': 7, 'run_input:failure': 4, 'rule:not_judgeable': 2})
broken 2 ['pi05_20261110_191618', 'pi05_20261110_192201']
targets 51
```

### manifest_unlabeled.csv（人の判定がない51本）

```
run_stem,latest_labeler,latest_outcome
pi05_20261030_184245,run_input,success
pi05_20261030_190659,run_input,failure
pi05_20261030_210821,rule,not_applicable
pi05_20261030_210954,run_input,success
pi05_20261031_175527,run_input,success
pi05_20261031_180435,run_input,success
pi05_20261031_181946,run_input,success
pi05_20261031_182545,run_input,success
pi05_20261031_184016,run_input,success
pi05_20261031_185428,rule,not_applicable
pi05_20261101_190347,run_input,success
pi05_20261101_190854,run_input,success
pi05_20261101_192101,run_input,success
pi05_20261101_192418,run_input,success
pi05_20261101_192758,run_input,failure
pi05_20261101_193041,run_input,success
pi05_20261101_193411,run_input,success
pi05_20261101_195421,rule,not_applicable
pi05_20261101_195807,rule,not_applicable
pi05_20261101_200345,rule,not_applicable
pi05_20261106_183926,run_input,success
pi05_20261106_184452,run_input,success
pi05_20261106_184650,run_input,success
pi05_20261106_184906,run_input,success
pi05_20261106_185050,run_input,failure
pi05_20261106_185554,run_input,success
pi05_20261110_111034,run_input,success
pi05_20261110_111726,rule,not_applicable
pi05_20261110_112346,run_input,success
pi05_20261110_112924,run_input,success
pi05_20261110_191905,rule,not_applicable
pi05_20261111_095426,run_input,success
pi05_20261111_095717,run_input,success
pi05_20261111_095917,run_input,success
pi05_20261111_100659,run_input,success
pi05_20261111_100857,run_input,success
pi05_20261111_101329,run_input,success
pi05_20261111_101720,run_input,success
pi05_20261111_101918,run_input,failure
pi05_20261111_102516,run_input,success
pi05_20261111_160851,run_input,success
pi05_20261113_193254,run_input,success
pi05_20261113_193542,run_input,success
pi05_20261113_193712,run_input,success
pi05_20261113_193939,run_input,success
pi05_20261113_194108,run_input,success
pi05_20261114_180457,run_input,success
pi05_20261114_180704,run_input,success
pi05_20261114_181300,run_input,success
pi05_20261114_182039,run_input,success
pi05_20261114_182211,run_input,success
```

### judge_v2.py の出力（人の判定がない51本）

```
Gemini の API キーを貼って Enter（画面には出ません。次回からは聞きません）: 
[1] pi05_20261030_184245 AI:success            確信0.98 持ったまま0.09 箱の中0.91 → 自動 前の印:run_input:success
[2] pi05_20261030_190659 AI:grasped_not_placed 確信0.80 持ったまま0.12 箱の中0.13 → 自動 前の印:run_input:failure
[3] pi05_20261030_210821 AI:no_motion          確信0.67 持ったまま0.29 箱の中0.15 → 自動 前の印:rule:not_applicable
[4] pi05_20261030_210954 AI:success            確信0.98 持ったまま0.06 箱の中0.93 → 自動 前の印:run_input:success
[5] pi05_20261031_175527 AI:success            確信0.92 持ったまま0.09 箱の中0.90 → 自動 前の印:run_input:success
[6] pi05_20261031_180435 AI:success            確信0.98 持ったまま0.08 箱の中0.91 → 自動 前の印:run_input:success
[7] pi05_20261031_181946 AI:success            確信0.97 持ったまま0.04 箱の中0.92 → 自動 前の印:run_input:success
[8] pi05_20261031_182545 AI:success            確信0.96 持ったまま0.06 箱の中0.90 → 自動 前の印:run_input:success
[9] pi05_20261031_184016 AI:success            確信0.96 持ったまま0.05 箱の中0.89 → 自動 前の印:run_input:success
[10] pi05_20261031_185428 AI:no_motion          確信0.52 持ったまま0.31 箱の中0.13 → 自動 前の印:rule:not_applicable
[11] pi05_20261101_190347 AI:success            確信0.97 持ったまま0.06 箱の中0.93 → 自動 前の印:run_input:success
[12] pi05_20261101_190854 AI:success            確信0.93 持ったまま0.08 箱の中0.93 → 自動 前の印:run_input:success
[13] pi05_20261101_192101 AI:success            確信0.98 持ったまま0.06 箱の中0.89 → 自動 前の印:run_input:success
[14] pi05_20261101_192418 AI:success            確信0.92 持ったまま0.04 箱の中0.93 → 自動 前の印:run_input:success
[15] pi05_20261101_192758 AI:grasped_not_placed 確信0.53 持ったまま0.09 箱の中0.10 → 自動 前の印:run_input:failure
[16] pi05_20261101_193041 AI:success            確信0.96 持ったまま0.05 箱の中0.88 → 自動 前の印:run_input:success
[17] pi05_20261101_193411 AI:success            確信0.98 持ったまま0.06 箱の中0.92 → 自動 前の印:run_input:success
[18] pi05_20261101_195421 AI:failed_grasp       確信0.41 持ったまま0.25 箱の中0.18 → 人へ 前の印:rule:not_applicable
[19] pi05_20261101_195807 AI:failed_grasp       確信0.62 持ったまま0.19 箱の中0.09 → 自動 前の印:rule:not_applicable
[20] pi05_20261101_200345 AI:failed_grasp       確信0.66 持ったまま0.23 箱の中0.14 → 自動 前の印:rule:not_applicable
[21] pi05_20261106_183926 AI:success            確信0.98 持ったまま0.06 箱の中0.92 → 自動 前の印:run_input:success
[22] pi05_20261106_184452 AI:success            確信0.97 持ったまま0.06 箱の中0.90 → 自動 前の印:run_input:success
[23] pi05_20261106_184650 AI:success            確信0.75 持ったまま0.12 箱の中0.66 → 自動 前の印:run_input:success
[24] pi05_20261106_184906 AI:success            確信0.98 持ったまま0.10 箱の中0.89 → 自動 前の印:run_input:success
[25] pi05_20261106_185050 AI:failed_grasp       確信0.49 持ったまま0.12 箱の中0.13 → 人へ 前の印:run_input:failure
[26] pi05_20261106_185554 AI:success            確信0.94 持ったまま0.10 箱の中0.92 → 自動 前の印:run_input:success
[27] pi05_20261110_111034 AI:success            確信0.98 持ったまま0.06 箱の中0.93 → 自動 前の印:run_input:success
[28] pi05_20261110_111726 AI:failed_grasp       確信0.50 持ったまま0.32 箱の中0.14 → 自動 前の印:rule:not_applicable
[29] pi05_20261110_112346 AI:success            確信0.98 持ったまま0.06 箱の中0.87 → 自動 前の印:run_input:success
[30] pi05_20261110_112924 AI:success            確信0.97 持ったまま0.06 箱の中0.94 → 自動 前の印:run_input:success
[31] pi05_20261110_191905 AI:failed_grasp       確信0.60 持ったまま0.20 箱の中0.12 → 自動 前の印:rule:not_applicable
[32] pi05_20261111_095426 AI:success            確信0.56 持ったまま0.20 箱の中0.19 → 自動 前の印:run_input:success
[33] pi05_20261111_095717 AI:success            確信0.99 持ったまま0.05 箱の中0.93 → 自動 前の印:run_input:success
[34] pi05_20261111_095917 AI:success            確信0.97 持ったまま0.10 箱の中0.90 → 自動 前の印:run_input:success
[35] pi05_20261111_100659 AI:success            確信0.94 持ったまま0.09 箱の中0.90 → 自動 前の印:run_input:success
[36] pi05_20261111_100857 AI:success            確信0.95 持ったまま0.08 箱の中0.90 → 自動 前の印:run_input:success
[37] pi05_20261111_101329 AI:success            確信0.93 持ったまま0.10 箱の中0.88 → 自動 前の印:run_input:success
[38] pi05_20261111_101720 AI:success            確信0.97 持ったまま0.05 箱の中0.92 → 自動 前の印:run_input:success
[39] pi05_20261111_101918 AI:grasped_not_placed 確信0.82 持ったまま0.07 箱の中0.09 → 自動 前の印:run_input:failure
[40] pi05_20261111_102516 AI:success            確信0.96 持ったまま0.08 箱の中0.90 → 自動 前の印:run_input:success
[41] pi05_20261111_160851 AI:success            確信0.97 持ったまま0.06 箱の中0.94 → 自動 前の印:run_input:success
[42] pi05_20261113_193254 AI:success            確信0.97 持ったまま0.09 箱の中0.92 → 自動 前の印:run_input:success
[43] pi05_20261113_193542 AI:success            確信0.98 持ったまま0.06 箱の中0.91 → 自動 前の印:run_input:success
[44] pi05_20261113_193712 AI:success            確信0.96 持ったまま0.07 箱の中0.91 → 自動 前の印:run_input:success
[45] pi05_20261113_193939 AI:success            確信0.92 持ったまま0.10 箱の中0.92 → 自動 前の印:run_input:success
[46] pi05_20261113_194108 AI:success            確信0.93 持ったまま0.10 箱の中0.90 → 自動 前の印:run_input:success
[47] pi05_20261114_180457 AI:success            確信0.98 持ったまま0.05 箱の中0.93 → 自動 前の印:run_input:success
[48] pi05_20261114_180704 AI:success            確信0.98 持ったまま0.10 箱の中0.92 → 自動 前の印:run_input:success
[49] pi05_20261114_181300 AI:success            確信0.99 持ったまま0.06 箱の中0.90 → 自動 前の印:run_input:success
[50] pi05_20261114_182039 AI:success            確信0.89 持ったまま0.12 箱の中0.74 → 自動 前の印:run_input:success
[51] pi05_20261114_182211 AI:success            確信0.97 持ったまま0.05 箱の中0.91 → 自動 前の印:run_input:success

本数 51 / 自動 49 / 人へ 2 / 入力トークン 520105（約 $0.0520）
(base) shimazueiichi@shimadzueiichinoMacBook-Pro decisions_test % 
```

推論のときに入力した印と AI の判定は、44本でそろいました（成功40本・失敗4本）。「対象外」などの決めの印（rule）が付いていた9本は、AI も「ほとんど動かない」か「つかめず」と答えていて、食い違いはありません。

人が見る回は3本になりました。確信度が0.5未満の2本（195421 の0.41、185050 の0.49）と、成功と答えたのに「箱の中」が0.19だった095426 です。エイイチが判定の画面で3本の録画を見て確定しました。

【画像】LOG520_05_verdict_viewer.png 推論の記録の判定の画面。左に176回の一覧と付いた判定、真ん中に上カメラの録画と関節の角度のグラフ、右に成功・失敗と pick・place のボタン、いま確定した回の一覧が並ぶ。右の一覧の上から4つが、この回に人が確かめた回

| 推論の記録 | 人の判定 | AI（2版） | 見立て |
|---|---|---|---|
| pi05_20261111_095426 | 成功 | 成功（確信度0.56・箱の中0.19） | 成否は合っていた。食い違いの決まりは空振り |
| pi05_20261101_195421 | 失敗（つかめなかった） | つかめず（0.41） | 合っていた |
| pi05_20261106_185050 | 失敗（つかんだが置けず） | つかめず（0.49） | 成否は合っていた。どこで失敗したかは外れ |

### 判定の表の、この回で見た推論の記録の行（確定の前後）

```
2026-10-31T18:53:55.872352,pi05_20261031_185246,yes,yes,success,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-06T18:44:31.023111,pi05_20261106_184312,no,no,failure,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-06T18:52:08.660638,pi05_20261106_185050,no,no,failure,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-11T09:57:02.585831,pi05_20261111_095426,yes,yes,success,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-11T10:22:02.476686,pi05_20261111_102043,no,no,failure,run_input,,,,{run_stem}.json の outcome を写した (記録したときの入力)
2026-11-14T20:31:34+09:00,pi05_20261101_195421,no,no,failure,ai,failure,[送ったチャンク 0] 全6枚を通じてロボットアームの爪は赤いブロックに近づいておらず、赤いブロックは元の位置に留まったままである。最終フレームでも赤いブロックは白い箱の外にあり、つかみ・配置ともに実行されていない。,top.mp4,
2026-11-14T22:44:54+09:00,pi05_20261101_195421,unknown,unknown,not_applicable,rule,failure,[送ったチャンク 0] 全6枚を通じてロボットアームの爪は赤いブロックに近づいておらず、赤いブロックは元の位置に留まったままである。最終フレームでも赤いブロックは白い箱の外にあり、つかみ・配置ともに実行されていない。,top.mp4,エイイチの決め 2026-11-14 依頼185 決め2: 送ったチャンク 0 (アームを動かしていない・試行になっていない)
2026-11-15T08:20:27+09:00,pi05_20261106_184312,no,unknown,failure,human_only,,,top.mp4,
2026-11-15T08:25:45+09:00,pi05_20261111_102043,no,no,failure,human_only,,,top.mp4,
2026-11-15T08:30:48+09:00,pi05_20261111_102043,yes,no,failure,human_only,,,top.mp4,
2026-11-15T15:37:36+09:00,pi05_20261031_185246,no,not_applicable,failure,human_only,,,top.mp4,ピントずれ・アーム動かず
2026-11-15T15:51:47+09:00,pi05_20261111_095426,yes,yes,success,human_only,,,top.mp4,
2026-11-15T15:54:31+09:00,pi05_20261101_195421,no,not_applicable,failure,human,failure,[送ったチャンク 0] 全6枚を通じてロボットアームの爪は赤いブロックに近づいておらず、赤いブロックは元の位置に留まったままである。最終フレームでも赤いブロックは白い箱の外にあり、つかみ・配置ともに実行されていない。,top.mp4,
2026-11-15T15:55:23+09:00,pi05_20261106_185050,yes,no,failure,human_only,,,top.mp4,
```

pi05_20261101_195421 は送ったチャンクが0の回で、これまでの決め（決め2）では「対象外」として成功率の分母に入れていなかった回です。人が「失敗」で確定したので、成功率の分母に入ります。

成功か失敗かは、人が確かめた範囲で、2版の外れは184312 の1本だけでした。一方で、失敗した回がどこで失敗したか（つかめなかったのか、つかんだが置けなかったのか）は、人と食い違う回が残ります（1版では失敗8本のうち3本、2版の51本では人が見た2本のうち1本）。どこで失敗したかの判定は、まだ人が見る必要があります。


## Gemini の判定は判定の表に入れず、別のファイルに置いた

はじめは、2版の判定を判定の表に「AI の行」として書き足すつもりでした。判定の画面のコード（`pi05/verdict_viewer/verdicts.py`）を読むと、確定の扱いはこうなっていました。

- 推論のときに入力した印（run_input）・人の行・決めの行（rule）は、どれも「確定」として扱う
- 確定した回には AI の行を足さない（依頼185 と codex のレビュー R2 で決めた）
- 人があとで確定するとき、直前の AI の行と同じかどうかで labeler（human か human_fixed_ai）が変わる。「AI が判定できないとした回」を印にする決め3も、AI の行を見ている

51本はすべて確定扱いだったので、書き足すと決まりに反し、ほかの動きの意味もずれます。そこで、Gemini の判定は別のファイルに分けました。MASTER の保存先テーブルに1行足してから置いています。

| データ | 置き場所 |
|---|---|
| Gemini Decisions API が付けた判定（2版・70行） | KIOXIA の `runs/pi05_policy_verdicts_gemini_v1.csv` |
| 作り方のコード（4つ）と、選んだ回の一覧 | r2r2r-scripts の `decisions_test/`（コミット f47799e） |
| 縮めた動画・最後のコマ・生の答え | 同じ `decisions_test/` の中。`.gitignore` で git に入れない |

### pi05_policy_verdicts_gemini_v1.csv を作ったコード

```python
cd $HOME/mnt/r2r2r-scripts/decisions_test && python3 - <<'EOF'
import csv,os
out=os.path.expanduser('~/mnt/r2r2r-data/runs/pi05_policy_verdicts_gemini_v1.csv')
assert not os.path.exists(out)
cols=['judged_at','run_stem','model','method','ai_outcome','ai_success_or_failure','ai_conf','route','p_grasped','p_holding_at_end','p_in_box_at_end','tokens','ms','set','human_or_previous_label_at_judge']
rows=[]
for f,setname in (('v2_manifest.csv','human_checked_19'),('v2_manifest_unlabeled.csv','unlabeled_51')):
    for r in csv.DictReader(open(f)):
        rows.append({'judged_at':'2026-11-15','run_stem':r['run_stem'],'model':'gemini-decision-1',
          'method':'v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ',
          'ai_outcome':r['ai_outcome'],'ai_success_or_failure':r['ai_success_or_failure'],'ai_conf':r['ai_conf'],'route':r['route'],
          'p_grasped':r['p_grasped'],'p_holding_at_end':r['p_holding_at_end'],'p_in_box_at_end':r['p_in_box_at_end'],
          'tokens':r['tokens'],'ms':r['ms'],'set':setname,
          'human_or_previous_label_at_judge':r.get('human') or r.get('previous_label','')})
with open(out,'w',newline='',encoding='utf-8') as f:
    w=csv.DictWriter(f,fieldnames=cols,lineterminator='\n'); w.writeheader(); w.writerows(rows)
print(len(rows),'rows ->',out)
EOF
```

### pi05_policy_verdicts_gemini_v1.csv（全70行）

```
judged_at,run_stem,model,method,ai_outcome,ai_success_or_failure,ai_conf,route,p_grasped,p_holding_at_end,p_in_box_at_end,tokens,ms,set,human_or_previous_label_at_judge
2026-11-15,pi05_20261110_112639,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.619,auto,0.763,0.292,0.357,9982,1389,human_checked_19,success
2026-11-15,pi05_20261114_182327,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.749,auto,0.636,0.119,0.701,14435,2752,human_checked_19,success
2026-11-15,pi05_20261101_190347,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.58,0.057,0.929,18888,3781,human_checked_19,success
2026-11-15,pi05_20261114_180457,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.983,auto,0.922,0.051,0.93,7792,1415,human_checked_19,success
2026-11-15,pi05_20261031_181946,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.902,0.04,0.919,22684,1758,human_checked_19,success
2026-11-15,pi05_20261106_184650,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.88,auto,0.83,0.118,0.824,8084,1282,human_checked_19,success
2026-11-15,pi05_20261031_185246,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.318,human,0.36,0.368,0.322,5383,1571,human_checked_19,failure
2026-11-15,pi05_20261113_193254,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.903,0.085,0.917,11150,1819,human_checked_19,success
2026-11-15,pi05_20261111_101720,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.969,auto,0.84,0.051,0.922,7646,1403,human_checked_19,success
2026-11-15,pi05_20261111_160851,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.969,auto,0.776,0.063,0.936,20202,1917,human_checked_19,success
2026-11-15,pi05_20261111_161402,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.652,auto,0.324,0.176,0.145,14654,2410,human_checked_19,failure
2026-11-15,pi05_20261111_101102,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.685,auto,0.172,0.087,0.098,5237,1870,human_checked_19,failure
2026-11-15,pi05_20261106_184312,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.862,auto,0.637,0.113,0.442,5894,1580,human_checked_19,failure
2026-11-15,pi05_20261031_183426,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.557,auto,0.194,0.094,0.094,22246,2397,human_checked_19,failure
2026-11-15,pi05_20261111_102043,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.612,auto,0.301,0.112,0.179,5967,1854,human_checked_19,failure
2026-11-15,pi05_20261030_185133,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.714,auto,0.122,0.08,0.072,48380,2233,human_checked_19,failure
2026-11-15,pi05_20261110_114106,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.875,auto,0.508,0.06,0.102,11734,1470,human_checked_19,failure
2026-11-15,pi05_20261111_101217,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.691,auto,0.141,0.102,0.087,5164,1491,human_checked_19,failure
2026-11-15,pi05_20261111_101557,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.64,auto,0.201,0.166,0.1,5456,1226,human_checked_19,failure
2026-11-15,pi05_20261030_184245,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.981,auto,0.758,0.085,0.911,17428,1747,unlabeled_51,run_input:success
2026-11-15,pi05_20261030_190659,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.799,auto,0.24,0.115,0.132,22246,2300,unlabeled_51,run_input:failure
2026-11-15,pi05_20261030_210821,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,no_motion,failure,0.673,auto,0.111,0.286,0.151,4872,1383,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261030_210954,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.976,auto,0.854,0.061,0.928,13997,1446,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_175527,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.925,auto,0.652,0.09,0.898,17793,3498,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_180435,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.975,auto,0.811,0.078,0.908,13194,3370,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_181946,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.902,0.04,0.919,22684,1771,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_182545,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.956,auto,0.765,0.058,0.9,24655,4829,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_184016,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.961,auto,0.889,0.047,0.886,11442,1693,unlabeled_51,run_input:success
2026-11-15,pi05_20261031_185428,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,no_motion,failure,0.518,auto,0.106,0.308,0.129,2536,1143,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261101_190347,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.58,0.057,0.929,18888,1995,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_190854,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.927,auto,0.803,0.083,0.931,14654,5285,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_192101,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.976,auto,0.592,0.062,0.89,11953,1572,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_192418,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.924,auto,0.801,0.04,0.934,13851,1793,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_192758,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.528,auto,0.215,0.09,0.098,10493,1616,unlabeled_51,run_input:failure
2026-11-15,pi05_20261101_193041,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.96,auto,0.793,0.052,0.881,13340,1921,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_193411,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.978,auto,0.801,0.06,0.915,14435,3338,unlabeled_51,run_input:success
2026-11-15,pi05_20261101_195421,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.413,human,0.205,0.25,0.182,2901,1316,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261101_195807,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.624,auto,0.182,0.19,0.088,15238,1903,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261101_200345,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.655,auto,0.183,0.235,0.138,1733,1411,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261106_183926,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.975,auto,0.75,0.056,0.918,13559,1729,unlabeled_51,run_input:success
2026-11-15,pi05_20261106_184452,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.971,auto,0.768,0.064,0.904,7062,1359,unlabeled_51,run_input:success
2026-11-15,pi05_20261106_184650,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.755,auto,0.888,0.122,0.656,8084,1356,unlabeled_51,run_input:success
2026-11-15,pi05_20261106_184906,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.981,auto,0.644,0.1,0.889,6697,1426,unlabeled_51,run_input:success
2026-11-15,pi05_20261106_185050,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.494,human,0.178,0.119,0.13,5675,1443,unlabeled_51,run_input:failure
2026-11-15,pi05_20261106_185554,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.938,auto,0.782,0.095,0.919,6843,1429,unlabeled_51,run_input:success
2026-11-15,pi05_20261110_111034,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.982,auto,0.91,0.055,0.934,21516,4607,unlabeled_51,run_input:success
2026-11-15,pi05_20261110_111726,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.502,auto,0.166,0.318,0.143,2609,1379,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261110_112346,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.98,auto,0.938,0.061,0.871,8303,2189,unlabeled_51,run_input:success
2026-11-15,pi05_20261110_112924,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.971,auto,0.908,0.064,0.937,8960,2462,unlabeled_51,run_input:success
2026-11-15,pi05_20261110_191905,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,failed_grasp,failure,0.603,auto,0.152,0.198,0.122,1587,1128,unlabeled_51,rule:not_applicable
2026-11-15,pi05_20261111_095426,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.557,auto,0.677,0.197,0.194,11077,3303,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_095717,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.991,auto,0.875,0.052,0.925,7938,2159,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_095917,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.973,auto,0.87,0.095,0.899,6040,2613,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_100659,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.941,auto,0.77,0.093,0.901,7500,1512,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_100857,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.953,auto,0.861,0.082,0.896,8084,2679,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_101329,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.928,auto,0.862,0.096,0.884,8376,2351,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_101720,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.969,auto,0.84,0.051,0.922,7646,2299,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_101918,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,grasped_not_placed,failure,0.819,auto,0.356,0.075,0.086,5675,1320,unlabeled_51,run_input:failure
2026-11-15,pi05_20261111_102516,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.956,auto,0.866,0.076,0.899,8230,1697,unlabeled_51,run_input:success
2026-11-15,pi05_20261111_160851,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.969,auto,0.776,0.063,0.936,20202,3657,unlabeled_51,run_input:success
2026-11-15,pi05_20261113_193254,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.972,auto,0.903,0.085,0.917,11150,3105,unlabeled_51,run_input:success
2026-11-15,pi05_20261113_193542,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.977,auto,0.8,0.062,0.906,6478,2067,unlabeled_51,run_input:success
2026-11-15,pi05_20261113_193712,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.965,auto,0.792,0.07,0.913,7062,1507,unlabeled_51,run_input:success
2026-11-15,pi05_20261113_193939,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.925,auto,0.635,0.096,0.918,6259,1935,unlabeled_51,run_input:success
2026-11-15,pi05_20261113_194108,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.934,auto,0.742,0.105,0.899,6989,2509,unlabeled_51,run_input:success
2026-11-15,pi05_20261114_180457,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.983,auto,0.922,0.051,0.93,7792,1569,unlabeled_51,run_input:success
2026-11-15,pi05_20261114_180704,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.977,auto,0.925,0.098,0.922,5748,1952,unlabeled_51,run_input:success
2026-11-15,pi05_20261114_181300,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.99,auto,0.808,0.062,0.904,7427,2304,unlabeled_51,run_input:success
2026-11-15,pi05_20261114_182039,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.891,auto,0.832,0.115,0.743,6040,1542,unlabeled_51,run_input:success
2026-11-15,pi05_20261114_182211,gemini-decision-1,v2: 動画640px2fps(low)+最後のコマ1280px(high)・質問4つ・確信度0.5未満は人へ,success,success,0.974,auto,0.734,0.051,0.909,5164,2054,unlabeled_51,run_input:success
```

### decisions_test/.gitignore

```
videos/
last_frames/
peek/
belt.png
*.jsonl
summary.txt
v2_*.csv
```


## 依頼211：判定の画面の AI を Claude から Gemini に切り替える

次に推論の記録が増えたときに使えるよう、判定の画面の「AI の先回り判定」を Gemini に切り替える依頼を、依頼箱に置きました。2版との違いは、録画の終わりの、人がブロックを箱から出していることのある区間を除くことと、「人へ」に回す回を判定の表では outcome を unknown にして残すことです。Claude の道は消さずに、`--ai-model claude` で選べるようにしています。この回の時点では、依頼箱で前の依頼の終わりを待っていて、結果はまだ出ていません。

ねらい：推論の記録が増えるたびに、人が見る回を確信度で絞る。
変わったこと：先回り判定が、6コマの静止画で文章を答える形から、動画と最後のコマで選択肢の確率を返す形になる（依頼211 が通れば）。
見込める効果：この回の51本と同じ割合なら、人が録画を見るのは6%ほどの回で済む見込み。新しい記録で確かめる。

### 依頼211 の依頼文

```markdown
---
作業フォルダ: /Users/shimazueiichi/r2r2r-scripts
上限時間: 90
---
# 依頼211：推論の記録の判定の画面の「AI の先回り判定」を Claude から Gemini Decisions API に切り替える

## ねらい

推論の記録（KIOXIA の `runs/pi05_policy/`）に AI が先に判定を付ける `pi05/verdict_viewer/seed_verdicts.py --ai`（依頼183）は、今は Claude Sonnet 4.6 に6コマの静止画を見せて文で答えさせている。
2026-11-15（LOG520）に Gemini Decisions API（モデル `gemini-decision-1`）で試したところ、動画をまるごと見て選択肢ごとの確率と確信度を返し、人が確かめた19本で成否が18本一致した。外れた1本も含め、誤りは「確信度が低い」か「答えと『箱の中にあるか』の確率が食い違う」ものに集まった。確信度で「人へ回す」回を分けられるので、先回り判定をこちらに切り替える。

お試しのコードは `decisions_test/judge_v2.py`（コミット f47799e）。結果は KIOXIA の `runs/pi05_policy_verdicts_gemini_v1.csv`。まずこの2つを読むこと。

## やること

1. `seed_verdicts.py` に Gemini で判定する道を足し、`--ai` の既定を Gemini にする。`--ai-model claude` を付けたときだけ今の Claude の道を使う（Claude の道は消さない）
2. Gemini への渡し方は `judge_v2.py` と同じ形にする。ただし次の1点を必ず変える：
   - **使う区間は、今の `mp4_active_end()` までに限る。** 動画も「最後のコマ」も、方策が動いていた区間の終わり（top_frame_log.csv の mode が wait / home でない最後のコマ）までから取る。終わりの wait / home では人がブロックを箱から出していることがあるため（seed_verdicts.py の冒頭の説明のとおり）。お試しの judge_v2.py は動画の本当の最後のコマを使っていたので、ここが違う
   - 動画：区間の終わりまでを 640px 幅・1秒2コマ・H.264（crf 30 くらい）に縮めて base64 で送る（`resolution: low`）。一時ファイルは KIOXIA にも元の記録の中にも作らない（`tempfile` の中で作って消す）
   - 最後のコマ：区間の終わりのコマを 1280px 幅の jpg で送る（`resolution: high`）
   - top.mp4 がない・読めない回は、今と同じく frames/ の画像（最後を含む最大6枚）を image のブロックで並べて送る。2枚に満たなければ API を呼ばずに not_judgeable（今と同じ）
   - 質問の4つ（grasped / holding_at_end / in_box_at_end / outcome）と選択肢の文は judge_v2.py のまま。frames/ のときは NOTE_FRAMES の内容を text のブロックで添える
3. 答えを判定の表の行にする対応：
   | Gemini の outcome | outcome | pick | place |
   |---|---|---|---|
   | success | success | yes | yes |
   | grasped_not_placed | failure | yes | no |
   | failed_grasp | failure | no | not_applicable |
   | no_motion | not_judgeable | unknown | unknown |
   - 次のどちらかに当たる回は、outcome を `unknown` にする（人へ回す）。pick / place も unknown。①outcome の確信度が 0.5 未満 ②outcome が success なのに in_box_at_end の確率が 0.5 未満
   - `ai_reason` の先頭に `[gemini-decision-1]` と `[送ったチャンク N]` を付け、続けて「選んだ答え・確信度・grasped / holding_at_end / in_box_at_end の確率・人へ回したならその理由（確信度が低い／箱の中と食い違い）」を短い日本語で書く。どのモデルが付けた行かを、ai_reason から分かるようにするため
   - labeler は今までどおり `ai`。verdicts.py の決まり（確定の行がある回には AI の行を足さない・追記だけ・マウントを確かめる）は変えない
4. API キーは `~/.config/p2m/gemini_api_key`（環境変数 `GEMINI_API_KEY` があればそちら）から読む。キーの中身を表示・ログ・報告に出さない。キーの形（先頭の文字）で確かめない（今のキーは `AIza` で始まらない）。ファイルがなければ、その回を飛ばして最後に数を出す（今の Claude の道の ApiUnavailable と同じ扱い）
5. 通信は今の call_api と同じく、429・5xx は待ってやり直す（3回まで）。400 は中身（先頭500字）を報告に書いて止める
6. `test_verdicts.py` にテストを足す：答え→行の対応の表の4通り、人へ回す2つの条件、ai_reason の先頭、キーのファイルがないときに飛ばすこと。API は呼ばずに、返事の JSON を作って試す。今のテスト 49 本も全部通すこと
7. 試し方：
   - `python3 pi05/verdict_viewer/seed_verdicts.py --ai --dry-run` で、対象の数と素材（top.mp4 / frames / なし）の数を出す
   - 本物の判定の表には書かない。KIOXIA の外の一時ファイル（判定の表の写し）を `--csv` などで渡し、人の判定がある回のうち2本（成功1本・失敗1本。`decisions_test/manifest.csv` から選ぶ）について、確定の行を除いた写しで Gemini を実際に呼び、書いた行を報告に全文で載せる。そうした引数がなければ、テスト用に足してよい
   - 本物の判定の表（`runs/pi05_policy_verdicts_v1.csv`）への `--ai` の本番実行はしない（今は確定していない回がないため。次に推論の記録が増えたときに流す）
8. `seed_verdicts.py` の冒頭の説明（docstring）と、判定の画面の「AI の判定（未確定）」の欄の説明に Claude と書いてあれば、Gemini に合わせて直す
9. 変えたファイルを1つずつ指定して add し、コミットする（`git add .` は使わない）。push はしない

## しないこと

- 判定の表（runs/pi05_policy_verdicts_v1.csv）と元の記録（runs/pi05_policy/）を書き換えない・消さない
- verdicts.py の確定の扱い（CONFIRMED_LABELERS）と決め2・決め3 を変えない
- 実機を動かさない

## 報告に書くこと

- 変えたファイルと、変えた所の要約
- テストの結果（本数・全部通ったか）
- dry-run の出力（全文）
- 一時ファイルで試した2本の、書いた行（全文）と、かかった時間・入力トークン
- 決めてほしいこと（あれば）
- 最後の1行に「判定：合格／止めた（決めてほしいことあり）／失敗」
```


## かかった費用と時間

| 試し | 本数 | 入力トークン | 費用（0.10ドル／100万トークン） | 1本の往復（中央値） |
|---|---|---|---|---|
| 画像1枚 | 1 | 784 | 約0.00008ドル | 1,888ms（1回だけ） |
| 1版（1回目） | 19 | 227,570 | 約0.023ドル | 1,882ms |
| 1版（2回目） | 19 | 227,570 | 約0.023ドル | 1,299ms |
| 2版（人の判定がある19本） | 19 | 250,978 | 約0.025ドル | 1,758ms |
| 2版（人の判定がない51本） | 51 | 520,105 | 約0.052ドル | 1,903ms |
| 合計 | 109回 | 1,227,007 | 約0.12ドル | ― |

往復の時間は、手元の Mac から動画を送って答えが返るまでです。長い録画の2本（入力4万トークン台）は9〜13秒かかりました。Google が言う150〜250ミリ秒は、モデルが答えを出す時間だけの値です。


## 次にやること：依頼211 を通し、新しい推論の記録で決まりを確かめる

- 依頼211 の報告を読み、通っていれば、次に π0.5 を実機で動かした記録に Gemini で先回り判定を付ける
- 「確信度0.5未満」「成功なのに箱の中0.5未満」を人へ回す決まりが、この回の19本・51本以外の記録でも誤りを拾えるかを数える
- どこで失敗したかの判定は、Gemini の答えを使わず、人が付ける

出典

- Erik Kokalj さんの X の投稿（ごみの選別ラインで Gemini Decisions API・Jev・OpenAI を比べたもの）：[x.com/erik_kokalj](https://x.com/erik_kokalj)
- Google：[Gemini Decisions API: Fast, calibrated multimodal decisions](https://blog.google/innovation-and-ai/technology/developers-tools/gemini-decisions-api/)
- Log#33（LOG497）：アームの成否判定を Google の Gemini Decision 1 に任せられるか
- Log#36（LOG512）：ロボットアームの学習データに、成否を付ける判定の画面を作った
