def process_and_evaluate(data): filename_in = data["filename_in"] filename_out = data["filename_out"] evaluator = data["evaluator"] processor = data["processor"] print("Processing file: {}".format(filename_in)) # Load image sample = Sample(filename_in, crop_bottom=0.10) # Compute segmentation final_img = processor.process(img=sample.get_image()) # Compute error s, _ = evaluator.evaluate(final_img) # dump segmentation print("Dumping file: {} - MAE: {}".format(filename_out, math.fabs(s))) cv2.imwrite(filename_out, final_img) return s
default=False, help="Put True if background is white") parser.add_argument("-invert_grain", type=bool, default=False, help="Put True if background is white") args = parser.parse_args() ###### # Step 1 : Align ##### # Look for the ref segment segment = Sample(args.seg_ref_path) segment = segment.get_image() if args.invert_segment: segment = np.invert( segment ) # we need the background to be black (default color for numpy transformation) segment[segment < 128] = 0 segment[segment >= 128] = 255 # Load gains grain = Sample(args.grain_ref_path) grain = grain.get_image() if args.invert_grain: grain = np.invert(