Browse Source

文生图通用接口新增传入图片数量

lh 1 month ago
parent
commit
1f97638f2f
1 changed files with 5 additions and 3 deletions
  1. 5 3
      app/Services/Anime/AnimeService.php

+ 5 - 3
app/Services/Anime/AnimeService.php

@@ -5713,11 +5713,12 @@ class AnimeService
      * 根据 inner_prompt_type 获取生成图片数量
      *
      * @param int $innerPromptType 内置提示词类型
+     * @param int $imageNum 传入的图片张数
      * @return int 图片数量
      */
-    public static function getInnerImageNum($innerPromptType = 0)
+    public static function getInnerImageNum($innerPromptType = 0, $imageNum)
     {
-        return (int)$innerPromptType === 2 ? 9 : 1;
+        return (int)$innerPromptType === 2 ? 9 : $imageNum;
     }
 
     /**
@@ -5750,6 +5751,7 @@ class AnimeService
         $ratio = getProp($data, 'ratio', '9:16');
         $resolution = getProp($data, 'resolution', '2k');
         $inner_prompt_type = getProp($data, 'inner_prompt_type', 0);
+        $imageNum = (int)getProp($data, 'image_num', 1);
         
         // 定义分辨率和宽高比对应的尺寸映射表
         $sizeMap = [
@@ -5838,7 +5840,7 @@ class AnimeService
 
         // 根据 inner_prompt_type 附加内置提示词并确定生成图片数量
         $prompt = self::appendInnerPrompt($prompt, $inner_prompt_type);
-        $imageNum = self::getInnerImageNum($inner_prompt_type);
+        $imageNum = self::getInnerImageNum($inner_prompt_type, $imageNum);
 
         try {
             // 创建图片生成任务