def generate_preds_softmax(outputs, target_size, threshold=0.5): preds = [] for output in outputs: cropped = crop_image_softmax(output, target_size=target_size) pred = binarize(cropped, threshold) preds.append(pred) return preds
def generate_preds(outputs, target_size): preds = [] for output in outputs: cropped = crop_image(output, target_size=target_size) pred = binarize(cropped, 0.5) preds.append(pred) return preds
def generate_preds(args, outputs, cls_preds, target_size, threshold=0.5): preds = [] for i, output in enumerate(outputs): resized_img = resize_image(output, target_size=target_size) pred = binarize(resized_img, threshold) if args.train_cls: pred = pred * cls_preds[i] preds.append(pred) return preds
def generate_preds(args, outputs, target_size, threshold=0.5): preds = [] for output in outputs: if args.pad_mode == 'resize': cropped = resize_image(output, target_size=target_size) else: cropped = crop_image(output, target_size=target_size) pred = binarize(cropped, threshold) preds.append(pred) return preds
def generate_preds(outputs, target_size, pad_mode, threshold=0.5): preds = [] for output in outputs: #print(output.shape) if pad_mode == 'resize': cropped = resize_image(output, target_size=target_size) else: cropped = crop_image_softmax(output, target_size=target_size) pred = binarize(cropped, threshold) preds.append(pred) return preds
def predict(seed: int, porosity_request: float): noise = generate_noise(seed, z_dim) porosity_request = porosity_format(porosity_request) global graph global session try: with session.as_default(): with graph.as_default(): image = generator.predict([noise, porosity_request]) except BaseException as e: print(e.args) image = postprocessing.binarize(image[0, :, :, :, 0]).astype(np.uint8) image = (image * 255).astype(np.uint8) return image