(batch_output, validation_images, validation_control_images,output_folder)
| 94 | return grid |
| 95 | |
| 96 | def save_combined_frames(batch_output, validation_images, validation_control_images,output_folder): |
| 97 | # Flatten batch_output, which is a list of lists of PIL Images |
| 98 | flattened_batch_output = [img for sublist in batch_output for img in sublist] |
| 99 | |
| 100 | # Combine frames into a list without converting (since they are already PIL Images) |
| 101 | combined_frames = validation_images + validation_control_images + flattened_batch_output |
| 102 | |
| 103 | # Calculate rows and columns for the grid |
| 104 | num_images = len(combined_frames) |
| 105 | cols = 3 # adjust number of columns as needed |
| 106 | rows = (num_images + cols - 1) // cols |
| 107 | timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") |
| 108 | |
| 109 | filename = f"combined_frames_{timestamp}.png" |
| 110 | # Create and save the grid image |
| 111 | grid = create_image_grid(combined_frames, rows, cols) |
| 112 | output_folder = os.path.join(output_folder, "validation_images") |
| 113 | os.makedirs(output_folder, exist_ok=True) |
| 114 | |
| 115 | # Now define the full path for the file |
| 116 | timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") |
| 117 | filename = f"combined_frames_{timestamp}.png" |
| 118 | output_loc = os.path.join(output_folder, filename) |
| 119 | |
| 120 | if grid is not None: |
| 121 | grid.save(output_loc) |
| 122 | else: |
| 123 | print("Failed to create image grid") |
| 124 | |
| 125 | |
| 126 |
nothing calls this directly
no test coverage detected