Files
settled-reach/tooling/trellis-batch.sh
T
jpmschweitzerandClaude Opus 4.6 98f8cbab0d fix(db): fix Trellis connector for updated Gradio API
- Add session_hash to all API calls (maintains gr.State between
  image_to_3d and extract_glb)
- Pass is_multiimage=False at position 2 (9-param image_to_3d)
- Pass output_buf=None at position 0 (3-param extract_glb)
- Document full API parameter reference and failure modes
- Add trellis-batch.sh for gentle sequential batch generation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 01:20:54 +01:00

94 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Batch Trellis generation — one at a time, gently.
# Usage: ./tooling/trellis-batch.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
INPUT_DIR=".tmp/image-gen/characters/bodies"
OUTPUT_DIR=".tmp/glb-gen/characters/bodies"
COOLDOWN=15 # seconds between jobs
MAX_RETRIES=3
RETRY_DELAY=60 # seconds before retry
mkdir -p "$OUTPUT_DIR"
TYPES=(
slim_m slim_f
average_m average_f
stocky_m stocky_f
tall_lean_m tall_lean_f
short_stout_m short_stout_f
athletic_m athletic_f
heavyset_m heavyset_f
petite_m petite_f
)
TOTAL=${#TYPES[@]}
SUCCESS=0
FAILED=0
echo "=== Trellis Batch: $TOTAL bodies ==="
echo " Cooldown: ${COOLDOWN}s between jobs"
echo " Retries: $MAX_RETRIES with ${RETRY_DELAY}s delay"
echo ""
for i in "${!TYPES[@]}"; do
TYPE="${TYPES[$i]}"
NUM=$((i + 1))
INPUT="$INPUT_DIR/${TYPE}.png"
OUTPUT="$OUTPUT_DIR/${TYPE}.glb"
# Skip if already generated
if [ -f "$OUTPUT" ]; then
echo "[$NUM/$TOTAL] $TYPE — already exists, skipping"
SUCCESS=$((SUCCESS + 1))
continue
fi
if [ ! -f "$INPUT" ]; then
echo "[$NUM/$TOTAL] $TYPE — input not found: $INPUT"
FAILED=$((FAILED + 1))
continue
fi
ATTEMPT=0
DONE=false
while [ "$ATTEMPT" -lt "$MAX_RETRIES" ] && [ "$DONE" = "false" ]; do
ATTEMPT=$((ATTEMPT + 1))
echo "[$NUM/$TOTAL] $TYPE (attempt $ATTEMPT/$MAX_RETRIES)..."
if python3 tooling/db/trellis_connector.py generate \
"$INPUT" \
--output "$OUTPUT" \
--simplify 0.95 \
--texture-size 1024 \
2>&1 | tee /dev/stderr | grep -q '"ok": true'; then
echo " OK"
SUCCESS=$((SUCCESS + 1))
DONE=true
else
echo " FAILED"
if [ "$ATTEMPT" -lt "$MAX_RETRIES" ]; then
echo " Waiting ${RETRY_DELAY}s before retry..."
sleep "$RETRY_DELAY"
else
echo " Giving up on $TYPE after $MAX_RETRIES attempts"
FAILED=$((FAILED + 1))
fi
fi
done
# Cooldown between successful jobs
if [ "$DONE" = "true" ] && [ "$NUM" -lt "$TOTAL" ]; then
echo " Cooling down ${COOLDOWN}s..."
sleep "$COOLDOWN"
fi
done
echo ""
echo "=== Results: $SUCCESS/$TOTAL succeeded, $FAILED failed ==="
ls -la "$OUTPUT_DIR"/*.glb 2>/dev/null || echo "No GLB files generated"