@@ -17,15 +17,15 @@ def __init__(self, output_folder: str, address: str = '127.0.0.1', port: int = 8
17
17
super ().__init__ ("/prompt" , output_folder , address , port )
18
18
self .workflow = workflow
19
19
20
- def generate_image (self , prompt : str , depth_map : str , negative_prompt : str = "text, watermark" , seed : int = - 1 , sampler : str = "euler" , steps : int = 30 , cfg_scale : float = 7 , width : int = 512 , height : int = 512 , cn_weight : float = 0.7 , cn_guidance : float = 1 , scheduler : str = '' , model : str = '' , cn_start : float = 0.0 , cn_end : float = 1.0 ) -> str :
20
+ def generate_image (self , prompt : str , depth_map : str , negative_prompt : str = "text, watermark" , seed : int = - 1 , sampler : str = "euler" , steps : int = 30 , cfg_scale : float = 7 , width : int = 512 , height : int = 512 , cn_weight : float = 0.7 , cn_guidance : float = 1 , scheduler : str = '' , model : str = '' , cn_start : float = 0.0 , cn_end : float = 1.0 , number_batches : int = 1 ) -> str :
21
21
"""Generate an image from text."""
22
- image_data = self .send_request (prompt , depth_map , negative_prompt , seed , sampler , steps , cfg_scale , width , height , cn_weight , cn_guidance , scheduler , model , cn_start , cn_end )
22
+ image_data = self .send_request (prompt , depth_map , negative_prompt , seed , sampler , steps , cfg_scale , width , height , cn_weight , cn_guidance , scheduler , model , cn_start , cn_end , number_batches )
23
23
if not image_data :
24
24
return None
25
25
return image_data [0 ]
26
26
27
27
28
- def send_request (self , prompt , depth_map , negative_prompt : str , seed : int , sampler : str , steps : int , cfg_scale : int , width : int , height : int , cn_weight : float , cn_guidance : float , scheduler : str = '' , model : str = '' , cn_start : float = 1.0 , cn_end : float = 1.0 ) -> bytes :
28
+ def send_request (self , prompt , depth_map , negative_prompt : str , seed : int , sampler : str , steps : int , cfg_scale : int , width : int , height : int , cn_weight : float , cn_guidance : float , scheduler : str = '' , model : str = '' , cn_start : float = 1.0 , cn_end : float = 1.0 , number_batches : int = 1 ) -> bytes :
29
29
30
30
path = self ._load_workflow (self .workflow )
31
31
with open (path ) as f :
@@ -44,7 +44,7 @@ def send_request(self, prompt, depth_map, negative_prompt: str, seed: int, sampl
44
44
workflow = self ._set_text_prompts (workflow , prompt , negative_prompt )
45
45
46
46
workflow = self ._set_sampler (workflow , sampler , cfg_scale , seed , steps , scheduler )
47
- workflow = self ._set_image_size (workflow , width , height )
47
+ workflow = self ._set_image_size (workflow , width , height , number_batches )
48
48
49
49
p = {"prompt" : workflow }
50
50
data = json .dumps (p )
@@ -126,9 +126,10 @@ def _set_sampler(self, data: dict, sampler: str, cfg: float, seed: int, steps: i
126
126
data ["3" ]["inputs" ]["scheduler" ] = scheduler
127
127
return data
128
128
129
- def _set_image_size (self , data : dict , width : int = 512 , height : int = 512 ) -> dict :
129
+ def _set_image_size (self , data : dict , width : int = 512 , height : int = 512 , batch_size : int = 1 ) -> dict :
130
130
data ["5" ]["inputs" ]["width" ] = width
131
131
data ["5" ]["inputs" ]["height" ] = height
132
+ data ["5" ]["inputs" ]["batch_size" ] = batch_size
132
133
return data
133
134
134
135
def _set_control_net (self , data :dict , depth_map : str , weight : float , guidance : float , start : float , end : float ) -> dict :
0 commit comments