Image - 2025-09-15 09:21
""" Generate 4 Seedream v4 images (no collage). Each request is one frame of the transformation. Replace API_ENDPOINT and API_KEY with your Seedream credentials. """ import requests, base64, os, time API_ENDPOINT = "https://api.seedream.example/v4/generate" # <<-- replace API_KEY = "YOUR_SEEDREAM_API_KEY" # <<-- replace headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} # Shared params base_payload = { "model": "seedream-v4", "aspect": "9:16", "resolution": "1536x2688", "seed": 424242, "guidance_scale": 8.0, "steps": 32, "sampler": "dpmpp_sde_karras", "n": 1, "negative_prompt": ( "Do not transform coat, torso, left arm, or face. " "No full-body robot. No extra limbs. No mutated anatomy. " "No watermark, no text. No lowres, no cartoon, no oversaturated colors. " "Keep coat fabric natural, not metallic." ) } # Prompts per frame prompts = [ # Frame 1 "(1) Fully human arm. Cinematic ultra-realistic photo of a casual Asian man in a long black Matrix-style coat. " "Right arm fully human from shoulder to fingertip, natural skin details. Calm, neutral face.", # Frame 2 "(2) Early transformation. Same man, same pose and framing. Slight facial tension. " "Right arm shows glowing blue-white nanotech circuit lines under skin, slim metallic segments forming at wrist/forearm. " "Coat and torso untouched.", # Frame 3 "(3) Mid transformation. Same man, same framing. Determined intense expression. " "Right arm half mechanical: smooth segmented biomechanical plating covers forearm/upper arm, glowing nanotech veins visible. " "Hand half human/half mechanical, panels sliding into place. Body unchanged.", # Frame 4 "(4) Final transformation. Same man, confident expression. " "Right arm fully transformed into sleek biomechanical nanotech: slim segmented plating hugging natural contours, luminous circuit lines, " "refined joints, articulated fingers. Design elegant, minimalistic, futuristic — not bulky. Coat and torso stay normal." ] os.makedirs("outputs", exist_ok=True) for i, p in enumerate(prompts, start=1): payload = dict(base_payload) payload["prompt"] = p print(f"Generating frame {i}...") r = requests.post(API_ENDPOINT, json=payload, headers=headers, timeout=120) data = r.json() # parse base64 b64 = None if "image_base64" in data: b64 = data["image_base64"] elif "images" in data and "b64_json" in data["images"][0]: b64 = data["images"][0]["b64_json"] elif "images" in data and "image_base64" in data["images"][0]: b64 = data["images"][0]["image_base64"] else: print("Unexpected response:", data) continue with open(f"outputs/frame_{i:02d}.png", "wb") as f: f.write(base64.b64decode(b64)) print(f"Saved outputs/frame_{i:02d}.png") time.sleep(1) print("All frames done.")
Free to start · Generate videos and images with AI in seconds