feat: Update regenerate_frame_image to use MediaService with RunningHub support

This commit is contained in:
empty
2026-01-06 18:11:19 +08:00
parent e29615a885
commit 4b86803692

View File

@@ -450,22 +450,19 @@ async def regenerate_frame_image(
raise HTTPException(status_code=400, detail="No image prompt available")
try:
# Import and use PixelleVideo core for image generation
# Import and use PixelleVideo core services
from api.dependencies import get_pixelle_video
from pixelle_video.models.storyboard import StoryboardFrame, StoryboardConfig
pixelle_video = get_pixelle_video()
# Generate image using ComfyKit
result = await pixelle_video.comfy(
workflow="image_gen",
# Use MediaService to generate image via RunningHub workflow
result = await pixelle_video.image(
prompt=prompt,
task_id=storyboard_id,
media_type="image",
)
if result and result.get("images"):
if result and result.url:
# Download and save image
image_url = result["images"][0]
import aiohttp
import os
@@ -473,17 +470,26 @@ async def regenerate_frame_image(
os.makedirs(output_dir, exist_ok=True)
image_path = f"{output_dir}/frame_{frame_index}_regenerated.png"
async with aiohttp.ClientSession() as session:
async with session.get(image_url) as resp:
if resp.status == 200:
with open(image_path, 'wb') as f:
f.write(await resp.read())
# Check if URL is remote or local
if result.url.startswith("http"):
async with aiohttp.ClientSession() as session:
async with session.get(result.url) as resp:
if resp.status == 200:
with open(image_path, 'wb') as f:
f.write(await resp.read())
else:
# Local file, copy it
import shutil
if os.path.exists(result.url):
shutil.copy2(result.url, image_path)
else:
image_path = result.url
# Update frame
target_frame["image_path"] = _path_to_url(image_path)
_storyboard_cache[storyboard_id] = storyboard
logger.info(f"Regenerated image for frame {frame_id}")
logger.info(f"Regenerated image for frame {frame_id} via RunningHub")
return RegenerateImageResponse(
image_path=target_frame["image_path"],