(allpaths,index,last_stylized,resolution,seed,last_mask,last_last_mask,fillindenoise,edgedenoise,target,diffuse,forwards)
| 89 | |
| 90 | |
| 91 | def prepare_request(allpaths,index,last_stylized,resolution,seed,last_mask,last_last_mask,fillindenoise,edgedenoise,target,diffuse,forwards): |
| 92 | |
| 93 | warped_path,flow,unused_mask,whitepixels,flow_img = raft.apply_flow_based_on_images(allpaths[index - 1],allpaths[index],last_stylized,resolution,index,temp_folder) |
| 94 | |
| 95 | #warped_path,flow,unused_mask,whitepixels,flow_img = raft.apply_flow_based_on_images(allpaths[index - 1],allpaths[index],allpaths[index],resolution,index,temp_folder) |
| 96 | if diffuse: |
| 97 | hed = gethedfromsd(warped_path,resolution) |
| 98 | hed = utilityb.mask_to_grayscale( utilityb.scale_mask_intensity(utilityb.base64_to_texture(hed),edgedenoise)) |
| 99 | #hardened_hed = utilityb.harden_mask(hed,True) |
| 100 | # flow_adjusted_mask = utilityb.modify_intensity_based_on_flow(hardened_hed,flow) |
| 101 | if last_mask is None: |
| 102 | last_mask = np.zeros((resolution,resolution)) |
| 103 | if last_last_mask is None: |
| 104 | last_last_mask = np.zeros((resolution,resolution)) |
| 105 | if diffuse: |
| 106 | combined_mask = utilityb.combine_masks([unused_mask,utilityb.scale_mask_intensity(last_mask,0.6),utilityb.scale_mask_intensity(last_last_mask,0.3),hed]) |
| 107 | #combine_mask_no_hed = utilityb.combine_masks([unused_mask,utilityb.scale_mask_intensity(last_mask,0.6),utilityb.scale_mask_intensity(last_last_mask,0.3)]) |
| 108 | #if whitepixels > 0: |
| 109 | #replaced = utilityb.replace_masked_area(flow,index,warped_path,unused_mask,warped_path) |
| 110 | if target is not None and index > 1: |
| 111 | replaced = utilityb.replaced_mask_from_other_direction_debug(index,Image.open(warped_path).convert("RGBA"),unused_mask,flow,Image.fromarray(cv2.cvtColor(utilityb.base64_to_texture( target), cv2.COLOR_BGR2RGB)).convert("RGBA"),forwards) |
| 112 | else: |
| 113 | replaced = utilityb.replaced_mask_from_other_direction_debug(index,Image.open(warped_path).convert("RGBA"),unused_mask,flow,None) |
| 114 | #else: |
| 115 | # replaced = warped_path |
| 116 | #replaced = replace_masked_area(flow,index,last_stylized,hed,allpaths[index]) |
| 117 | |
| 118 | |
| 119 | # Save the mask as a PNG file in the temporary folder |
| 120 | file_path = os.path.join("debug2", f'mask{index}.png') |
| 121 | cv2.imwrite(file_path, unused_mask) |
| 122 | |
| 123 | |
| 124 | |
| 125 | if diffuse: |
| 126 | return send_request_in_chain(last_stylized,allpaths[index],replaced,utilityb.texture_to_base64(combined_mask),index,seed,fillindenoise,resolution),unused_mask,flow_img |
| 127 | else: |
| 128 | return replaced, unused_mask,flow_img |
| 129 | # return send_request(last_stylized,y_folder,allpaths[index],replaced,hed,index) |
| 130 | |
| 131 |
no test coverage detected