diff --git a/src/server/dcp_server/segmentationclasses.py b/src/server/dcp_server/segmentationclasses.py index 01b2c1d..c5637be 100644 --- a/src/server/dcp_server/segmentationclasses.py +++ b/src/server/dcp_server/segmentationclasses.py @@ -20,6 +20,7 @@ def __init__(self, imagestorage, runner, model): self.imagestorage = imagestorage self.runner = runner self.model = model + self.no_files_msg = "No image-label pairs found in curated directory" async def segment_image(self, input_path, list_of_images): """Segments images from the given directory @@ -65,7 +66,7 @@ async def train(self, input_path): train_img_mask_pairs = self.imagestorage.get_image_seg_pairs(input_path) if not train_img_mask_pairs: - return "No images and segs found" + return self.no_files_msg imgs, masks = self.imagestorage.prepare_images_and_masks_for_training(train_img_mask_pairs) model_save_path = await self.runner.train.async_run(imgs, masks) diff --git a/src/server/dcp_server/serviceclasses.py b/src/server/dcp_server/serviceclasses.py index bc8375d..410ee42 100644 --- a/src/server/dcp_server/serviceclasses.py +++ b/src/server/dcp_server/serviceclasses.py @@ -127,8 +127,9 @@ async def train(input_path): """ print("Calling retrain from server.") # Train the model - model_path = await self.segmentation.train(input_path) - msg = "Success! Trained model saved in: " + model_path + msg = await self.segmentation.train(input_path) + if msg!=self.segmentation.no_files_msg: + msg = "Success! Trained model saved in: " + msg return msg return svc