Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a31d11f
Add DeepSeek support with independent API keys and rewrite README
deltaaa00 Nov 15, 2026
d499773
Transfer map topics to video titles and add render progress and stickers
deltaaa00 Nov 15, 2026
8b1d57e
Add global horizontal label shift and move repaint controls to main p…
deltaaa00 Nov 15, 2026
1254049
Show repaint status overlay on map preview
deltaaa00 Nov 15, 2026
d54bf68
Persist run history in browser and expire runs after 24 hours
deltaaa00 Nov 15, 2026
fdb0bef
Optimize video rendering: FFmpeg background prep, static layer flatte…
deltaaa00 Nov 15, 2026
e7cbd9e
Add AI response cache, pooled HTTP session, and multipart video upload
deltaaa00 Nov 15, 2026
f3d743d
Optimize map generation with cached region-ID LUT and image caches
deltaaa00 Nov 15, 2026
7051dad
Fix initial palette theme preview and transfer map theme to video studio
deltaaa00 Nov 15, 2026
ab7f545
Add parallel per-map CSV batch generation with progress bar and mode …
deltaaa00 Nov 15, 2026
58b7ddd
Add drag and drop support for CSV batch upload
deltaaa00 Nov 15, 2026
dca8466
Show loaded CSV filename clearly in batch upload UI
deltaaa00 Nov 15, 2026
7399703
Download all batch maps as ZIP archive named by topic with underscores
deltaaa00 Nov 15, 2026
c6a1c6c
Show per-map generation duration in batch results list
deltaaa00 Nov 15, 2026
f072de4
Add DeepSeek web search tool toggle in web UI and API
deltaaa00 Nov 15, 2026
95d6328
Implement DeepSeek function-calling web search with max-requests slider
deltaaa00 Nov 15, 2026
0d69ceb
Use reliable Wikipedia search API and instruct DeepSeek to use web_se…
deltaaa00 Nov 15, 2026
9a6e936
Add clarifying comments to DeepSeek web search and budget loop
deltaaa00 Nov 15, 2026
1d5ce89
docs: add concise docstrings to map/ helper functions
deltaaa00 Nov 15, 2026
bb267be
docs: add docstrings and inline comments to web, cli, auth, and cache…
deltaaa00 Nov 15, 2026
96d1ed7
docs: add docstrings and inline comments to video/progress/sticker mo…
deltaaa00 Nov 15, 2026
2da9de9
Move extra sticker drawing engine to extra_stickers.py
deltaaa00 Nov 15, 2026
fc84c0e
Fix worker packaging, batch ZIP downloads and web search caching
deltaaa00 Nov 15, 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
2 changes: 1 addition & 1 deletion Dockerfile.ytserver
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt


COPY yt-dlp_serv.py sticker_themes.py server_runtime.py ./
COPY yt-dlp_serv.py sticker_themes.py extra_stickers.py server_runtime.py render_progress.py ./
COPY resources/fonts/ resources/fonts/

EXPOSE 8080
Expand Down
81 changes: 81 additions & 0 deletions benchmarks/bench_video_render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Render benchmark for the video worker.

Usage: python benchmarks/bench_video_render.py [--seconds 3] [--module yt-dlp_serv.py]

Renders a short synthetic clip through /api/render_video with visual effects
on and off (plus a draft run) and prints wall-clock timings. ``--module`` lets
you time another revision of the worker file for before/after comparisons.
"""
import argparse
import base64
import importlib.util
import os
import sys
import tempfile
import time

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def load_worker(path):
sys.path.insert(0, ROOT)
spec = importlib.util.spec_from_file_location('bench_worker', path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--seconds', type=float, default=3.0)
parser.add_argument('--module', default=os.path.join(ROOT, 'yt-dlp_serv.py'))
parser.add_argument('--repeat', type=int, default=1)
args = parser.parse_args()

import numpy as np
from moviepy import VideoClip
from PIL import Image

worker = load_worker(args.module)
tmp = tempfile.mkdtemp()
worker.RENDER_DIR = tmp
background = os.path.join(tmp, 'bg.mp4')
# Moving gradient at 1280x720 so scaling, cropping and blur do real work.
xs = np.linspace(0, 255, 1280)[None, :, None]

def frame(t):
base = (xs + 120 * t) % 255
return np.broadcast_to(base, (720, 1280, 3)).astype(np.uint8)

VideoClip(frame, duration=args.seconds).write_videofile(
background, fps=30, codec='libx264', logger=None)
map_png = os.path.join(tmp, 'map.png')
Image.new('RGBA', (1600, 1200), (40, 160, 90, 255)).save(map_png)
material = {
'map_file': base64.b64encode(open(map_png, 'rb').read()).decode(),
'background_video': base64.b64encode(open(background, 'rb').read()).decode(),
'video_title': 'Benchmark title\nSecond line',
'duration': args.seconds,
'watermark_text': 'automap', 'watermark_stars': True,
'subscribe_badge': True, 'subscribe_delay': 0.5,
'top_left_sticker': 'star', 'top_right_sticker': 'heart',
'allow_remote_stickers': False,
}
client = worker.app.test_client()
cases = [('effects on', {'visual_effects': True}),
('effects off', {'visual_effects': False}),
('draft, effects on', {'visual_effects': True, 'draft': True})]
for name, extra in cases:
best = None
for _ in range(args.repeat):
start = time.perf_counter()
response = client.post('/api/render_video', json={**material, **extra})
elapsed = time.perf_counter() - start
assert response.status_code == 200, response.json
best = elapsed if best is None else min(best, elapsed)
os.remove(response.json['file_path'])
print(f'{name:20s} {best:6.2f}s for {args.seconds:g}s clip')


if __name__ == '__main__':
main()
19 changes: 12 additions & 7 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Command-line interface (`automap make` and `automap batch`) for AutoMap."""

import os
from pathlib import Path

Expand All @@ -33,6 +35,9 @@
"gemini-3-flash-preview",
"gemma-4-31b-it",
"gemma-4-26b-a4b-it",
# Current DeepSeek API model identifiers: https://api-docs.deepseek.com/
"deepseek-flash",
"deepseek-v4-pro",
]


Expand Down Expand Up @@ -98,7 +103,7 @@ def main():
@click.option("--key",
"api_key",
default=None,
help="Gemini API key for this run (overrides GEMINI_API_KEY env var).")
help="API key for the selected model provider (overrides its environment key).")
@click.option("--temperature", type=click.FloatRange(0, 2), default=None,
help="AI sampling randomness, from 0 to 2. Omit to use the model default.")
def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, show_result, verbose, api_key, temperature):
Expand All @@ -110,7 +115,7 @@ def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, s
"""
# Lazy import so `automap --help` stays fast and doesn't require API keys.
from map import log
from map.functions import AIServiceError
from map.functions import AIServiceError, provider_for_model, provider_key_name
from map.auto_map import auto_map

ai_options = {}
Expand All @@ -129,7 +134,7 @@ def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, s

# A key passed on the command line overrides the env var for this run only.
if api_key:
os.environ["GEMINI_API_KEY"] = api_key
os.environ[provider_key_name(provider_for_model(model))] = api_key

# Click accepts mixed-case choices; the renderer compares lowercase names.
try:
Expand Down Expand Up @@ -201,17 +206,17 @@ def make(prompt, mode, map_type, size_mod, optional_feature, model, font_name, s
@click.option("--key",
"api_key",
default=None,
help="Gemini API key for this run (overrides GEMINI_API_KEY env var).")
help="API key for the selected model provider (overrides its environment key).")
def batch(ideas_file, output_dir, mode, map_type, size_mod, optional_feature, model, font_name, verbose, api_key):
"""Generate multiple maps from ideas listed in a .csv IDEAS_FILE."""
from map import log
from map.functions import AIServiceError
from map.functions import AIServiceError, provider_for_model, provider_key_name
from map.auto_map import auto_map
from map.functions import load_ideas_from_file, slugify_prompt

log.set_verbose(verbose)
if api_key:
os.environ["GEMINI_API_KEY"] = api_key
os.environ[provider_key_name(provider_for_model(model))] = api_key

try:
ideas = load_ideas_from_file(ideas_file)
Expand Down Expand Up @@ -253,7 +258,7 @@ def batch(ideas_file, output_dir, mode, map_type, size_mod, optional_feature, mo
font_name=item_font,
show_result=False,
io_res=True,
api_key=api_key,
api_key=api_key if provider_for_model(item_model) == provider_for_model(model) else None,
**style_options,
)
except AIServiceError as error:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
WEB_PASSWORD: "${WEB_PASSWORD:-deltaaa00!}"
WEB_SECRET_KEY: "${WEB_SECRET_KEY:-}"
GEMINI_API_KEY: "${GEMINI_API_KEY:-}"
DEEPSEEK_API_KEY: "${DEEPSEEK_API_KEY:-}"
YTDLP_URL: http://yt-dlp-worker:8080
volumes:
- automap-session:/app/instance
Expand Down
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
GEMINI_API_KEY=your_google_ai_studio_key
DEEPSEEK_API_KEY=your_deepseek_api_key
SERVER=TRUE
WEB_LOGIN=deltaaa
WEB_PASSWORD=deltaaa00!
Expand Down
115 changes: 115 additions & 0 deletions extra_stickers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""Offline vector artwork for the extended sticker library."""


def draw_extra_sticker(kind, draw, s, outline, ow, star_polygon_fn=None):
"""Draw an extended procedural sticker onto a Pillow ImageDraw canvas.

Returns True if `kind` is handled by this library, False otherwise.
"""
extras = {
'mountain', 'volcano', 'island', 'rainbow', 'moon', 'rain', 'robot',
'satellite', 'laptop', 'graduation', 'medal', 'cat', 'dog', 'fish', 'burger', 'train',
}
if kind not in extras:
return False

def coords(values):
return tuple(value * s for value in values)

def ellipse(box, color):
draw.ellipse(coords(box), fill=color, outline=outline, width=ow)

def rect(box, color):
draw.rounded_rectangle(coords(box), radius=ow * 2, fill=color, outline=outline, width=ow)

def poly(points, color):
draw.polygon([coords(point) for point in points], fill=color, outline=outline, width=ow)

def line(points, color, width=None):
draw.line([coords(point) for point in points], fill=color, width=width or ow)

blue, gold, white = '#38bdf8', '#fbbf24', '#f8fafc'
if kind in ('mountain', 'volcano'):
if kind == 'volcano':
ellipse((.35, .06, .61, .3), '#94a3b8')
poly([(.08, .9), (.48, .2), (.9, .9)], '#78716c' if kind == 'volcano' else '#64748b')
poly([(.32, .49), (.48, .2), (.66, .49), (.53, .42), (.43, .51)], '#fb923c' if kind == 'volcano' else white)
if kind == 'volcano':
line([(.49, .42), (.6, .65), (.55, .86)], '#ef4444', ow * 2)
elif kind == 'island':
ellipse((.07, .65, .94, .94), blue)
ellipse((.19, .66, .84, .87), gold)
line([(.48, .74), (.6, .3)], '#92400e', ow * 2)
for tip in [(.23, .3), (.38, .1), (.82, .16), (.91, .39), (.7, .5)]:
poly([(.58, .31), tip, (.55, .4)], '#22c55e')
elif kind == 'rainbow':
for index, color in enumerate(['#ef4444', '#fb923c', gold, '#22c55e', '#38bdf8', '#a78bfa']):
inset = index * .055
draw.arc(coords((.08 + inset, .13 + inset, .92 - inset, .97 - inset)), 180, 360, fill=color, width=ow * 2)
elif kind == 'moon':
ellipse((.15, .08, .85, .89), gold)
draw.ellipse(coords((.37, .01, .99, .7)), fill=(0, 0, 0, 0))
elif kind == 'rain':
for box in [(.12, .25, .57, .61), (.31, .12, .75, .61), (.56, .29, .9, .63)]:
ellipse(box, '#cbd5e1')
for x in (.27, .5, .73):
line([(x, .7), (x - .06, .89)], blue, ow * 2)
elif kind == 'robot':
line([(.5, .1), (.5, .25)], '#94a3b8')
ellipse((.44, .05, .56, .18), '#ef4444')
rect((.14, .25, .86, .86), '#94a3b8')
for x in (.27, .6):
ellipse((x, .39, x + .13, .55), blue)
rect((.29, .65, .71, .77), white)
line([(.43, .66), (.43, .76)], outline)
line([(.57, .66), (.57, .76)], outline)
elif kind == 'satellite':
rect((.05, .3, .31, .73), '#2563eb')
rect((.69, .3, .95, .73), '#2563eb')
line([(.29, .52), (.72, .52)], gold, ow * 2)
rect((.35, .25, .65, .78), '#cbd5e1')
poly([(.41, .24), (.64, .07), (.76, .28)], white)
elif kind == 'laptop':
rect((.18, .16, .82, .69), '#475569')
rect((.25, .24, .75, .6), blue)
poly([(.18, .69), (.82, .69), (.96, .86), (.04, .86)], '#cbd5e1')
elif kind == 'graduation':
rect((.25, .4, .74, .75), '#1e293b')
poly([(.07, .34), (.5, .13), (.94, .34), (.5, .55)], '#334155')
line([(.51, .34), (.83, .42), (.83, .78)], gold, ow * 2)
elif kind == 'medal':
poly([(.25, .09), (.47, .09), (.61, .51), (.36, .55)], '#ef4444')
poly([(.54, .09), (.76, .09), (.64, .55), (.4, .51)], '#2563eb')
ellipse((.2, .4, .81, .96), gold)
if star_polygon_fn is not None:
draw.polygon(star_polygon_fn(s * .5, s * .68, s * .18, s * .08), fill=white)
elif kind in ('cat', 'dog'):
color = '#fb923c' if kind == 'cat' else '#b45309'
if kind == 'cat':
poly([(.18, .43), (.18, .12), (.47, .35)], color)
poly([(.53, .35), (.83, .12), (.83, .43)], color)
else:
ellipse((.04, .19, .34, .72), color)
ellipse((.67, .19, .96, .72), color)
ellipse((.18, .27, .83, .91), color)
for x in (.33, .62):
ellipse((x, .47, x + .06, .55), outline)
ellipse((.36, .61, .66, .81), '#ffedd5')
poly([(.44, .64), (.59, .64), (.51, .73)], outline)
elif kind == 'fish':
poly([(.59, .51), (.92, .27), (.92, .79)], '#fb923c')
ellipse((.08, .26, .74, .8), blue)
ellipse((.22, .41, .29, .48), outline)
line([(.47, .39), (.41, .54), (.49, .65)], '#2563eb')
elif kind == 'burger':
ellipse((.13, .13, .88, .62), gold)
for y, color in [(.44, '#22c55e'), (.56, '#ef4444'), (.68, '#78350f'), (.78, gold)]:
rect((.12, y, .89, y + .12), color)
elif kind == 'train':
rect((.21, .09, .8, .8), '#ef4444')
rect((.28, .22, .72, .48), blue)
for x in (.3, .61):
ellipse((x, .59, x + .1, .69), gold)
line([(.27, .83), (.14, .95)], outline, ow * 2)
line([(.74, .83), (.87, .95)], outline, ow * 2)
return True
Loading
Loading