This commit is contained in:
cmdr2 2022-12-12 15:44:22 +05:30
parent fb32a38d96
commit 07bd580050
2 changed files with 11 additions and 4 deletions

View File

@ -48,6 +48,9 @@ class Response:
self.images = images self.images = images
def json(self): def json(self):
del self.render_request.init_image
del self.render_request.init_image_mask
res = { res = {
"status": 'succeeded', "status": 'succeeded',
"render_request": self.render_request.dict(), "render_request": self.render_request.dict(),

View File

@ -33,7 +33,7 @@ def init(device):
device_manager.device_init(context, device) device_manager.device_init(context, device)
def make_images(req: GenerateImageRequest, task_data: TaskData, data_queue: queue.Queue, task_temp_images: list, step_callback): def make_images(req: GenerateImageRequest, task_data: TaskData, data_queue: queue.Queue, task_temp_images: list, step_callback):
log.info(f'request: {req.dict()}') log.info(f'request: {get_printable_request(req)}')
log.info(f'task data: {task_data.dict()}') log.info(f'task data: {task_data.dict()}')
try: try:
@ -120,9 +120,7 @@ def construct_response(images: list, task_data: TaskData, base_seed: int):
] ]
def get_metadata_entries(req: GenerateImageRequest, task_data: TaskData): def get_metadata_entries(req: GenerateImageRequest, task_data: TaskData):
metadata = req.dict() metadata = get_printable_request(req)
del metadata['init_image']
del metadata['init_image_mask']
metadata.update({ metadata.update({
'use_stable_diffusion_model': task_data.use_stable_diffusion_model, 'use_stable_diffusion_model': task_data.use_stable_diffusion_model,
'use_vae_model': task_data.use_vae_model, 'use_vae_model': task_data.use_vae_model,
@ -133,6 +131,12 @@ def get_metadata_entries(req: GenerateImageRequest, task_data: TaskData):
return [metadata.copy().update({'seed': req.seed + i}) for i in range(req.num_outputs)] return [metadata.copy().update({'seed': req.seed + i}) for i in range(req.num_outputs)]
def get_printable_request(req: GenerateImageRequest):
metadata = req.dict()
del metadata['init_image']
del metadata['init_image_mask']
return metadata
def make_filename_callback(req: GenerateImageRequest, suffix=None): def make_filename_callback(req: GenerateImageRequest, suffix=None):
def make_filename(i): def make_filename(i):
img_id = base64.b64encode(int(time.time()+i).to_bytes(8, 'big')).decode() # Generate unique ID based on time. img_id = base64.b64encode(int(time.time()+i).to_bytes(8, 'big')).decode() # Generate unique ID based on time.