From 9fc96dc18c0a6e5af1b84959e67c9e1e22d58f6d Mon Sep 17 00:00:00 2001 From: Robert Kiewisz <56911280+RRobert92@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:49:23 +0200 Subject: [PATCH] Update predictor.py --- tardis_em/utils/predictor.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tardis_em/utils/predictor.py b/tardis_em/utils/predictor.py index fbc32fd..0bacbf4 100644 --- a/tardis_em/utils/predictor.py +++ b/tardis_em/utils/predictor.py @@ -884,6 +884,11 @@ def log_tardis(self, id_: int, i: Union[str, np.ndarray], log_id: float): self.tardis_progress(title=self.title, **config) def save_semantic_mask(self, i): + self.log_prediction.append(f"Semantic Prediction: {i[:-self.in_format]}" + f" | Number of pixels: {np.sum(self.image)}") + with open(join("Predictions", "prediction_log.txt"), "w") as f: + f.write(" \n".join(self.log_prediction)) + if self.output_format.startswith("mrc"): to_mrc( data=self.image, @@ -912,11 +917,13 @@ def save_semantic_mask(self, i): join(self.am_output, f"{i[:-self.in_format]}_semantic.npy"), self.image ) - self.log_prediction.append(f"Semantic Prediction: {i[:-self.in_format]}") - with open(join("Predictions", "prediction_log.txt"), "w") as f: + def save_instance_PC(self, i): + self.log_prediction.append( + f"Instance Prediction: {i[:-self.in_format]}; Number of segments: {np.max(self.segments[:, 0])}" + ) + with open() as f: f.write(" \n".join(self.log_prediction)) - def save_instance_PC(self, i): if self.output_format.endswith("amSG") and self.predict in [ "Actin", "Microtubule", @@ -1063,12 +1070,6 @@ def save_instance_PC(self, i): self.segments, ) - self.log_prediction.append( - f"Instance Prediction: {i[:-self.in_format]}; Number of segments: {np.max(self.segments[:, 0])}" - ) - with open() as f: - f.write(" \n".join(self.log_prediction)) - def _debug(self, id_name: str, debug_id: str): if self.debug: if debug_id == "cnn":