fix: remove redundant useless loop (#4656)

fix: potential error of undefined variable

https://github.com/comfyanonymous/ComfyUI/discussions/4650
This commit is contained in:
Dr.Lt.Data 2024-08-29 06:46:30 +09:00 committed by GitHub
parent d31e226650
commit 34eda0f853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 29 deletions

View File

@ -41,15 +41,14 @@ def get_images(ws, prompt):
continue #previews are binary data continue #previews are binary data
history = get_history(prompt_id)[prompt_id] history = get_history(prompt_id)[prompt_id]
for o in history['outputs']: for node_id in history['outputs']:
for node_id in history['outputs']: node_output = history['outputs'][node_id]
node_output = history['outputs'][node_id] images_output = []
if 'images' in node_output: if 'images' in node_output:
images_output = [] for image in node_output['images']:
for image in node_output['images']: image_data = get_image(image['filename'], image['subfolder'], image['type'])
image_data = get_image(image['filename'], image['subfolder'], image['type']) images_output.append(image_data)
images_output.append(image_data) output_images[node_id] = images_output
output_images[node_id] = images_output
return output_images return output_images

View File

@ -95,17 +95,16 @@ class ComfyClient:
pass # Probably want to store this off for testing pass # Probably want to store this off for testing
history = self.get_history(prompt_id)[prompt_id] history = self.get_history(prompt_id)[prompt_id]
for o in history['outputs']: for node_id in history['outputs']:
for node_id in history['outputs']: node_output = history['outputs'][node_id]
node_output = history['outputs'][node_id] result.outputs[node_id] = node_output
result.outputs[node_id] = node_output images_output = []
if 'images' in node_output: if 'images' in node_output:
images_output = [] for image in node_output['images']:
for image in node_output['images']: image_data = self.get_image(image['filename'], image['subfolder'], image['type'])
image_data = self.get_image(image['filename'], image['subfolder'], image['type']) image_obj = Image.open(BytesIO(image_data))
image_obj = Image.open(BytesIO(image_data)) images_output.append(image_obj)
images_output.append(image_obj) node_output['image_objects'] = images_output
node_output['image_objects'] = images_output
return result return result

View File

@ -109,15 +109,14 @@ class ComfyClient:
continue #previews are binary data continue #previews are binary data
history = self.get_history(prompt_id)[prompt_id] history = self.get_history(prompt_id)[prompt_id]
for o in history['outputs']: for node_id in history['outputs']:
for node_id in history['outputs']: node_output = history['outputs'][node_id]
node_output = history['outputs'][node_id] images_output = []
if 'images' in node_output: if 'images' in node_output:
images_output = [] for image in node_output['images']:
for image in node_output['images']: image_data = self.get_image(image['filename'], image['subfolder'], image['type'])
image_data = self.get_image(image['filename'], image['subfolder'], image['type']) images_output.append(image_data)
images_output.append(image_data) output_images[node_id] = images_output
output_images[node_id] = images_output
return output_images return output_images