Repository navigation
Expand file tree
/
Copy pathdemo.sh
More file actions
executable file
·116 lines (97 loc) · 3.92 KB
/
Copy pathdemo.sh
File metadata and controls
executable file
·116 lines (97 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Demo script for gnarly CLI - showcases each CA rule and option
set -e
DEMO_DIR="demo_output"
mkdir -p "$DEMO_DIR"
# Create a test image if none exists
if [ ! -f "$DEMO_DIR/test.png" ]; then
echo "Creating test image..."
python3 -c "
from PIL import Image
import random
# Create a colorful gradient with some noise
img = Image.new('RGB', (400, 400))
pixels = img.load()
for y in range(400):
for x in range(400):
r = int(255 * x / 400)
g = int(255 * y / 400)
b = int(128 + 127 * ((x + y) % 50) / 50)
# Add some noise
if random.random() > 0.95:
r, g, b = 255, 255, 255
pixels[x, y] = (r, g, b)
img.save('$DEMO_DIR/test.png')
print('Created test image: $DEMO_DIR/test.png')
"
fi
echo ""
echo "=== Gnarly Demo ==="
echo "Output directory: $DEMO_DIR"
echo ""
# Short frames for quick demo
FRAMES=60
FPS=15
echo "[1/5] Conway (Classic Game of Life)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/01_conway.mp4" \
--rule Conway --frames $FRAMES --fps $FPS --blend-alpha 0.4
echo "[2/5] HighLife (Replicators)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/02_highlife.mp4" \
--rule HighLife --frames $FRAMES --fps $FPS --blend-alpha 0.5
echo "[3/5] Seeds (Explosive growth)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/03_seeds.mp4" \
--rule Seeds --frames $FRAMES --fps $FPS --blend-alpha 0.3
echo "[4/5] Custom (Dense patterns)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/04_custom.mp4" \
--rule Custom --frames $FRAMES --fps $FPS --blend-alpha 0.4
echo "[5/5] DivisorRule (Modulo patterns)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/05_divisor.mp4" \
--rule DivisorRule --divisor 3 --frames $FRAMES --fps $FPS --blend-alpha 0.35
echo ""
echo "=== Grid Scale Comparison ==="
echo "[Bonus] Fine detail (grid-scale 2)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/06_fine_detail.mp4" \
--rule Conway --grid-scale 2 --frames $FRAMES --fps $FPS --blend-alpha 0.4
echo "[Bonus] Blocky (grid-scale 8)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/07_blocky.mp4" \
--rule Conway --grid-scale 8 --frames $FRAMES --fps $FPS --blend-alpha 0.4
echo ""
echo "=== Zoom Effect (no GPU) ==="
echo "[8/10] Zoom oscillation..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/08_zoom.mp4" \
--rule Conway --zoom --zoom-speed 1.03 --zoom-min 1.0 --zoom-max 1.5 \
--frames $FRAMES --fps $FPS --blend-alpha 0.4
echo ""
echo "=== Face Detection (no GPU) ==="
echo "[9/10] Face detection (downloads dlib model on first run)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/09_faces.mp4" \
--rule Conway --faces --frames $FRAMES --fps $FPS --blend-alpha 0.4 \
2>&1 || echo " (No faces in test image - expected)"
echo ""
echo "=== GPU Effects (requires CUDA) ==="
# Check for GPU
if python -c "import torch; exit(0 if torch.cuda.is_available() else 1)" 2>/dev/null; then
echo "GPU detected - running GPU effects..."
echo "[10a] Deep Dream..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/10_deep_dream.mp4" \
--rule Conway --deep-dream --dream-iterations 10 \
--frames 30 --fps $FPS --blend-alpha 0.3
echo "[10b] YOLO Detection..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/11_yolo_detect.mp4" \
--rule Conway --detect --detect-model yolo --detect-confidence 0.3 \
--frames $FRAMES --fps $FPS --blend-alpha 0.4
echo "[10c] Morph Effect (Stable Diffusion)..."
python -m gnarly "$DEMO_DIR/test.png" -o "$DEMO_DIR/12_morph.mp4" \
--rule Conway --detect --morph --morph-style surrealistic \
--frames 30 --fps $FPS --blend-alpha 0.4
else
echo "No CUDA GPU detected - skipping GPU effects"
echo " (Deep Dream, Detection, Morph require GPU)"
fi
echo ""
echo "=== Done! ==="
echo "Output files:"
ls -lh "$DEMO_DIR"/*.mp4
echo ""
echo "Play with: mpv $DEMO_DIR/*.mp4"
echo "Or open individually in your video player."