[diffusion] fix: fix reading multiple prompts from prompt file (#19075)
Signed-off-by: Sushil Dubey <sushil.dubey@intel.com>
This commit is contained in:
@@ -361,8 +361,6 @@ class SamplingParams:
|
|||||||
|
|
||||||
# TODO: SamplingParams should not rely on ServerArgs
|
# TODO: SamplingParams should not rely on ServerArgs
|
||||||
pipeline_config = server_args.pipeline_config
|
pipeline_config = server_args.pipeline_config
|
||||||
if not isinstance(self.prompt, str):
|
|
||||||
raise TypeError(f"`prompt` must be a string, but got {type(self.prompt)}")
|
|
||||||
|
|
||||||
if self.guidance_scale is None:
|
if self.guidance_scale is None:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ This module provides a consolidated interface for generating images/videos using
|
|||||||
diffusion models.
|
diffusion models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import dataclasses
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@@ -165,15 +166,21 @@ class DiffGenerator:
|
|||||||
"""
|
"""
|
||||||
# 1. prepare requests
|
# 1. prepare requests
|
||||||
prompts = self._resolve_prompts(sampling_params_kwargs.get("prompt"))
|
prompts = self._resolve_prompts(sampling_params_kwargs.get("prompt"))
|
||||||
sampling_params = SamplingParams.from_user_sampling_params_args(
|
sampling_params_orig = SamplingParams.from_user_sampling_params_args(
|
||||||
self.server_args.model_path,
|
self.server_args.model_path,
|
||||||
server_args=self.server_args,
|
server_args=self.server_args,
|
||||||
**sampling_params_kwargs,
|
**sampling_params_kwargs,
|
||||||
)
|
)
|
||||||
|
user_output_file_name = sampling_params_kwargs.get("output_file_name")
|
||||||
|
|
||||||
requests: list[Req] = []
|
requests: list[Req] = []
|
||||||
for p in prompts:
|
for p in prompts:
|
||||||
sampling_params.prompt = p
|
sampling_params = dataclasses.replace(
|
||||||
|
sampling_params_orig,
|
||||||
|
prompt=p,
|
||||||
|
output_file_name=user_output_file_name,
|
||||||
|
)
|
||||||
|
sampling_params._set_output_file_name()
|
||||||
req = prepare_request(
|
req = prepare_request(
|
||||||
server_args=self.server_args,
|
server_args=self.server_args,
|
||||||
sampling_params=sampling_params,
|
sampling_params=sampling_params,
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ def prepare_request(
|
|||||||
|
|
||||||
req.adjust_size(server_args)
|
req.adjust_size(server_args)
|
||||||
|
|
||||||
|
if not isinstance(req.prompt, str):
|
||||||
|
raise TypeError(f"`prompt` must be a string, but got {type(req.prompt)}")
|
||||||
|
|
||||||
if (req.width is not None and req.width <= 0) or (
|
if (req.width is not None and req.width <= 0) or (
|
||||||
req.height is not None and req.height <= 0
|
req.height is not None and req.height <= 0
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user