From c24c2fd0e0583e2809ee1b03db20f46444ba3d2a Mon Sep 17 00:00:00 2001
From: Xinfan Chen <2024111082@stu.hit.edu.cn>
Date: Fri, 24 Apr 2026 13:47:48 +0800
Subject: [PATCH] add deepseek-v4 wan2.7-image gpt-image-2
---
aigc-director/aigc-claw/backend/tool/image_dashscope.py | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/aigc-director/aigc-claw/backend/tool/image_dashscope.py b/aigc-director/aigc-claw/backend/tool/image_dashscope.py
index 25d162c..cf63149 100644
--- a/aigc-director/aigc-claw/backend/tool/image_dashscope.py
+++ b/aigc-director/aigc-claw/backend/tool/image_dashscope.py
@@ -20,7 +20,7 @@
dashscope.base_http_api_url = self.base_url
self.image_processor = ImageProcessor()
- def generate_image(self, prompt, model="wan2.6-t2i", size="1024*1024", n=1, session_id=None, save_dir=None):
+ def generate_image(self, prompt, model="wan2.7-image", size="1024*1024", n=1, session_id=None, save_dir=None):
"""
Text to Image generation using DashScope
"""
@@ -65,7 +65,7 @@
logging.error(f"Error in generate_image (DashScope): {e}")
return []
- def edit_image(self, prompt, image_urls, model="wan2.6-image", size="1920*1080", n=1, session_id=None, save_dir=None):
+ def edit_image(self, prompt, image_urls, model="wan2.7-image", size="1920*1080", n=1, session_id=None, save_dir=None):
"""
Image editing/compositing using DashScope ImageGeneration
"""
@@ -136,11 +136,12 @@
if __name__ == "__main__":
import sys
- import tempfile
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from config import Config
print("=== DashScope 图片生成可用性测试 ===")
+ MODELS=["wan2.6-t2i", "wan2.7-image", "wan2.7-image-pro"]
+ save_dir = "code/result/image/test_avail"
api_key = Config.DASHSCOPE_API_KEY
base_url = Config.DASHSCOPE_BASE_URL
if not api_key:
@@ -149,14 +150,42 @@
print(f" API Key: {api_key[:6]}***{api_key[-4:]}")
print(f" Base URL: {base_url}")
client = DashScopeClient(api_key=api_key, base_url=base_url)
+
+ # 文生图
+ print("\n=== 文生图测试 ===")
prompt = "一只橘猫躺在阳光下的窗台上,水彩画风格"
- print(f"Prompt: {prompt}")
- with tempfile.TemporaryDirectory() as tmp:
+ for model in MODELS:
+ print(f"\nPrompt: {prompt}")
+ print(f"model: {model}")
+ os.makedirs(save_dir, exist_ok=True)
t0 = time.time()
try:
paths = client.generate_image(
- prompt=prompt, model="wan2.6-t2i",
- size="1024*1024", save_dir=tmp,
+ prompt=prompt, model=model,
+ size="1024*1024", save_dir=save_dir,
+ )
+ elapsed = time.time() - t0
+ if paths:
+ print(f"✓ 生成 {len(paths)} 张图片 ({elapsed:.1f}s): {paths}")
+ else:
+ print(f"✗ 返回空列表 ({elapsed:.1f}s)")
+ except Exception as e:
+ print(f"✗ 失败: {e}")
+ sys.exit(1)
+
+ # 图生图
+ print("\n=== 图生图测试 ===")
+ img_path = "code/result/image/test_avail/test_input.png"
+ prompt = "在这张图片的基础上,添加一些飞舞的樱花花瓣,绘制为水彩画风格"
+ for model in MODELS:
+ print(f"\nPrompt: {prompt}")
+ print(f"model: {model}")
+ os.makedirs(save_dir, exist_ok=True)
+ t0 = time.time()
+ try:
+ paths = client.edit_image(
+ prompt=prompt, image_urls=[img_path], model=model,
+ size="1024*1024", save_dir=save_dir,
)
elapsed = time.time() - t0
if paths:
--
Gitblit v1.8.0