Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3fded76
Add LAM_WebRender and LAM_Audio2Expression for lip-sync implementatio…
claude Feb 5, 2026
b5a6c0f
Fix TTS lip sync timing issues in LAMAvatar
claude Feb 5, 2026
c21bb46
Fix TTS lip sync by tracking ttsActive state ourselves
claude Feb 5, 2026
ef3863f
Fix TTS lip sync timing issues in LAMAvatar
claude Feb 5, 2026
c39a1d6
Simplify TTS-Sync mode - remove legacy method calls from event handlers
claude Feb 5, 2026
38740a4
Update audio2exp-service for real LAM Audio2Expression model
claude Feb 5, 2026
4a65f2b
Add .gitignore to audio2exp-service to exclude exp/ logs
claude Feb 5, 2026
03c8379
Fix TTS lip sync for multiple audio segments
claude Feb 5, 2026
f3fb25b
Fix audio2exp to generate frames for full audio duration
claude Feb 5, 2026
a5c01d8
Align audio2exp-service with official OpenAvatarChat patterns
claude Feb 5, 2026
4667b07
Add Dockerfile for real LAM model deployment
claude Feb 5, 2026
ffc3c81
Update Dockerfile for CPU-based LAM Audio2Expression deployment
claude Feb 5, 2026
75e00b0
Add Docker container paths for LAM model deployment
claude Feb 5, 2026
07da7dc
Use GCS for model storage instead of embedding in Docker image
claude Feb 5, 2026
4607708
Add .gcloudignore for Cloud Build to include LAM_Audio2Expression
claude Feb 6, 2026
4967bc9
Add LAM_Audio2Expression with CPU support to audio2exp-service
claude Feb 6, 2026
47d0e26
Fix PyTorch 2.6 compatibility: add weights_only=False to torch.load
claude Feb 6, 2026
49bdd39
Add --no-cache to Docker build to prevent stale code deployment
claude Feb 6, 2026
0b722bf
Fix cloudbuild.yaml: use BUILD_ID instead of COMMIT_SHA, increase mem…
claude Feb 7, 2026
5d4efd4
Fix model loading: decompress gzipped model file after download
claude Feb 7, 2026
0e2eaa1
Fix model download: remove incorrect gunzip for non-gzipped .tar file
claude Feb 7, 2026
3a19148
Fix mock mode: add GCS model verification and save_path fix
claude Feb 7, 2026
0963704
Fix model loading: auto-decompress gzipped checkpoint from HuggingFace
claude Feb 7, 2026
5c938c1
Fix Cloud Build timeout: increase to 60 min, add high-CPU machine
claude Feb 7, 2026
5defd58
Increase Cloud Build timeout to 90 min for deployment step
claude Feb 7, 2026
0bd418d
Fix Cloud Run startup timeout: background model initialization
claude Feb 7, 2026
3199c71
Fix start.sh: run model download in foreground for proper logging
claude Feb 7, 2026
f118a8d
Use Python GCS client for model download instead of gsutil
claude Feb 7, 2026
e91ac81
Use Cloud Storage FUSE for model loading instead of download
claude Feb 7, 2026
3248d6b
Fix model filename to match GCS: LAM_audio2exp_streaming.tar
claude Feb 7, 2026
2882ffa
Reduce max-instances to 5 for Cloud Run quota limits
claude Feb 7, 2026
348581a
Reduce max-instances to 4 for safer quota margin
claude Feb 7, 2026
db3ab05
Add /debug endpoint for Cloud Run troubleshooting
claude Feb 7, 2026
4ba662c
Simplify deployment: bake models into Docker image
claude Feb 7, 2026
5dcef58
Add handoff documentation for LAM_Audio2Expression analysis
claude Feb 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions ANALYSIS_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# LAM_Audio2Expression 解析・実装依頼

## 依頼の背景

Audio2ExpressionサービスをGoogle Cloud Runにデプロイしようと48時間以上、40回以上試行したが、モデルが「mock」モードのままで正しく初期化されない。対症療法的な修正を繰り返しても解決できないため、根本的なアプローチの見直しが必要。

## 前任AIの反省点

**重要**: 前任AI(Claude)は以下の問題を抱えていた:

1. **古い知識ベースからの推論に依存**
- 一般的な「Cloud Runデプロイ」パターンを適用しようとした
- LAM_Audio2Expression固有の設計思想を理解できていなかった

2. **表面的なコード理解**
- コードを読んだが、なぜそのように設計されているかを理解していなかった
- 元々どのような環境・ユースケースを想定したコードなのかを考慮しなかった

3. **対症療法の繰り返し**
- ログからエラーを見つけ→修正→デプロイ→また別のエラー、の無限ループ
- 根本原因を特定せず、見えている症状だけを修正し続けた

4. **思い込み**
- 「モデルの読み込みや初期化がうまくいっていない」と決めつけていた
- 問題はそこではなく、もっと根本的なアプローチの誤りである可能性がある

**この解析を行う際は、上記の落とし穴にハマらないよう注意してください。**

## 解析対象コード

### 主要ファイル

**1. audio2exp-service/app.py** (現在のサービス実装)
- FastAPI を使用したWebサービス
- `/health`, `/debug`, `/api/audio2expression`, `/ws/{session_id}` エンドポイント
- `Audio2ExpressionEngine` クラスでモデル管理

**2. LAM_Audio2Expression/engines/infer.py**
- `InferBase` クラス: モデル構築の基底クラス
- `Audio2ExpressionInfer` クラス: 音声→表情推論
- `infer_streaming_audio()`: リアルタイムストリーミング推論

**3. LAM_Audio2Expression/models/network.py**
- `Audio2Expression` クラス: PyTorchニューラルネットワーク
- wav2vec2 エンコーダー + Identity Encoder + Decoder構成

**4. LAM_Audio2Expression/engines/defaults.py**
- `default_config_parser()`: 設定ファイル読み込み
- `default_setup()`: バッチサイズ等の設定計算
- `create_ddp_model()`: 分散データ並列ラッパー

## 具体的な解析依頼

### Q1: モデル初期化が完了しない根本原因

```python
# app.py での初期化
self.infer = INFER.build(dict(type=cfg.infer.type, cfg=cfg))
self.infer.model.eval()
```

この処理がCloud Run環境で正常に完了しない理由を特定してください。

考えられる原因:
- [ ] メモリ不足 (8GiBで足りない?)
- [ ] CPU環境での動作制限
- [ ] 分散処理設定が単一インスタンスで問題を起こす
- [ ] ファイルシステムの書き込み権限
- [ ] タイムアウト (コールドスタート時間)
- [ ] その他

### Q2: default_setup() の問題

```python
# defaults.py
def default_setup(cfg):
world_size = comm.get_world_size() # Cloud Runでは1
cfg.num_worker = cfg.num_worker if cfg.num_worker is not None else mp.cpu_count()
cfg.num_worker_per_gpu = cfg.num_worker // world_size
assert cfg.batch_size % world_size == 0 # 失敗する可能性?
```

推論時にこの設定が問題を起こしていないか確認してください。

### Q3: ロガー設定の問題

```python
# infer.py
self.logger = get_root_logger(
log_file=os.path.join(cfg.save_path, "infer.log"),
file_mode="a" if cfg.resume else "w",
)
```

Cloud Runのファイルシステムでログファイル作成が失敗する可能性を確認してください。

### Q4: wav2vec2 モデル読み込み

```python
# network.py
if os.path.exists(pretrained_encoder_path):
self.audio_encoder = Wav2Vec2Model.from_pretrained(pretrained_encoder_path)
else:
config = Wav2Vec2Config.from_pretrained(wav2vec2_config_path)
self.audio_encoder = Wav2Vec2Model(config) # ランダム重み!
```

- wav2vec2-base-960h フォルダの構成は正しいか?
- HuggingFaceからのダウンロードが必要なファイルはないか?

### Q5: 適切なデプロイ方法

Cloud Runが不適切な場合、以下の代替案を検討:
- Google Compute Engine (GPU インスタンス)
- Cloud Run Jobs (バッチ処理)
- Vertex AI Endpoints
- Kubernetes Engine

## 期待する成果

### 1. 分析結果
- 根本原因の特定
- なぜ40回以上の試行で解決できなかったかの説明

### 2. 修正されたコード
```
audio2exp-service/
├── app.py # 修正版
├── Dockerfile # 必要なら修正
└── cloudbuild.yaml # 必要なら修正
```

### 3. 動作確認方法
```bash
# ヘルスチェック
curl https://<service-url>/health
# 期待する応答: {"model_initialized": true, "mode": "inference", ...}

# 推論テスト
curl -X POST https://<service-url>/api/audio2expression \
-H "Content-Type: application/json" \
-d '{"audio_base64": "...", "session_id": "test"}'
```

## 技術スペック

### モデル仕様
| 項目 | 値 |
|------|-----|
| 入力サンプルレート | 24kHz (API) / 16kHz (内部) |
| 出力フレームレート | 30 fps |
| 出力次元 | 52 (ARKit blendshape) |
| モデルファイルサイズ | ~500MB (LAM) + ~400MB (wav2vec2) |

### デプロイ環境
| 項目 | 値 |
|------|-----|
| プラットフォーム | Cloud Run Gen 2 |
| リージョン | asia-northeast1 |
| メモリ | 8GiB |
| CPU | 4 |
| max-instances | 4 |

### 依存関係 (requirements.txt)
```
torch==2.0.1
torchaudio==2.0.2
transformers==4.30.2
librosa==0.10.0
fastapi==0.100.0
uvicorn==0.23.0
numpy==1.24.3
scipy==1.11.1
pydantic==2.0.3
```

## ファイルの場所

```bash
# プロジェクトルート
cd /home/user/LAM_gpro

# メインサービス
cat audio2exp-service/app.py

# 推論エンジン
cat audio2exp-service/LAM_Audio2Expression/engines/infer.py

# ニューラルネットワーク
cat audio2exp-service/LAM_Audio2Expression/models/network.py

# 設定
cat audio2exp-service/LAM_Audio2Expression/engines/defaults.py
cat audio2exp-service/LAM_Audio2Expression/configs/lam_audio2exp_config_streaming.py
```

---

以上、よろしくお願いいたします。
1 change: 1 addition & 0 deletions LAM_Audio2Expression
Submodule LAM_Audio2Expression added at 02a703
Loading