| 88 | ] |
| 89 | |
| 90 | def construct_edit_image(self, edit_image, edit_mask): |
| 91 | if edit_image is not None and edit_mask is not None: |
| 92 | edit_image_rgb = pillow_convert(edit_image, "RGB") |
| 93 | edit_image_rgba = pillow_convert(edit_image, "RGBA") |
| 94 | edit_mask = pillow_convert(edit_mask, "L") |
| 95 | |
| 96 | arr1 = np.array(edit_image_rgb) |
| 97 | arr2 = np.array(edit_mask)[:, :, np.newaxis] |
| 98 | result_array = np.concatenate((arr1, arr2), axis=2) |
| 99 | layer = Image.fromarray(result_array) |
| 100 | |
| 101 | ret_data = { |
| 102 | "background": edit_image_rgba, |
| 103 | "composite": edit_image_rgba, |
| 104 | "layers": [layer] |
| 105 | } |
| 106 | return ret_data |
| 107 | else: |
| 108 | return None |
| 109 | |
| 110 | def create_ui(self): |
| 111 | with gr.Row(equal_height=True, visible=True): |