Skip to content
Notifications
Clear all

How can I batch process 50 product prompts efficiently?

1 Posts
1 Users
0 Reactions
5 Views
(@consulting_contractor_mike)
Estimable Member
Joined: 4 months ago
Posts: 123
Topic starter   [#12132]

I've been evaluating the Luma Dream Machine API for a potential client project involving bulk generation of product visualization concepts. The core requirement is processing around 50 distinct, detailed product prompts (e.g., "a minimalist titanium coffee maker on a marble countertop, morning light, shallow depth of field") to generate consistent, high-quality images for an e-commerce prototype. The naive approach—sequential API calls—is inefficient and fails the cost/time optimization test.

My primary concerns are managing the asynchronous workflow, handling rate limits and potential errors without losing prompts, and ensuring output consistency across the batch. The official documentation touches on batch operations but is light on real-world implementation patterns for this scale. I'm particularly interested in the interplay between the `num_cfg_scale` and `num_inference_steps` parameters when aiming for uniform style across multiple prompts. Does tweaking these for speed (lower steps) sacrifice the consistency needed for a product lineup?

Here's a proof-of-concept script skeleton I've been testing, which uses a queue and retry logic. The main hurdles are the variable job completion times and the 429 errors that appear under load.

```python
import asyncio
import aiohttp
from tenacity import retry, stop_after_attempt, wait_exponential

# Pseudocode for batch processor
class LumaBatchProcessor:
def __init__(self, api_key, concurrency_limit=5):
self.semaphore = asyncio.Semaphore(concurrency_limit)
self.queue = asyncio.Queue()

@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=2, max=10))
async def generate_single(self, session, prompt, params):
async with self.semaphore:
# API call logic here, with specific params
# await session.post(...)
pass

async def process_batch(self, prompt_list):
tasks = []
async with aiohttp.ClientSession() as session:
for prompt in prompt_list:
task = asyncio.create_task(self.generate_single(session, prompt, self.base_params))
tasks.append(task)
results = await asyncio.gather(*tasks, return_exceptions=True)
# Need robust error handling for each result
return results
```

Key questions for the community:
* What's the practical concurrency limit you've found stable for the Dream Machine API before hitting throttling? Is 5 too aggressive?
* For product images, are there specific `model` parameters or `scheduler` settings that yield more deterministic/repeatable results across a batch, even if it costs more per call?
* How are you handling failed generations in the middle of a large batch? Is there a built-in idempotency key or should we implement external job tracking?
* Any experience with the "video" mode for generating slight variations (e.g., color swaps) being more efficient than 50 separate image calls?

The goal is to move from a working prototype to a production-ready batch system. I'm looking for lessons from those who have pushed beyond simple single-image generation.

- Mike


Mike


   
Quote