diff --git a/MedSAM/MedSAMLite/MedSAMLite.py b/MedSAM/MedSAMLite/MedSAMLite.py old mode 100644 new mode 100755 index f048495..264fb2a --- a/MedSAM/MedSAMLite/MedSAMLite.py +++ b/MedSAM/MedSAMLite/MedSAMLite.py @@ -280,7 +280,7 @@ def setup(self) -> None: # Buttons self.ui.pbUpgrade.connect('clicked(bool)', lambda: self.logic.run_on_background(self.logic.upgrade, (True,), 'Checking for updates...')) - self.ui.pbSendImage.connect('clicked(bool)', lambda: self.logic.sendImage()) + self.ui.pbSendImage.connect('clicked(bool)', lambda: self.logic.sendImage(partial=False)) self.ui.pbSegment.connect('clicked(bool)', lambda: self.logic.applySegmentation()) self.ui.pbCTprep.setIcon(QIcon(os.path.join(self.logic.server_dir, 'CT.jpg'))) @@ -744,9 +744,8 @@ def sendImage(self, partial=False, serverUrl='http://127.0.0.1:5555', numpyServe ########################### # Timer - if self.timer is None: - self.timer = QTimer() - self.timer.timeout.connect(lambda: self.progressCheck(partial)) + self.timer = QTimer() + self.timer.timeout.connect(lambda: self.progressCheck(partial)) ########################### self.progressbar = slicer.util.createProgressDialog(autoClose=False) self.progressbar.minimum = 0 @@ -805,7 +804,7 @@ def singleSegmentation(self, serverUrl): def applySegmentation(self, serverUrl='http://127.0.0.1:5555'): if self.widget.ui.pbSegment.text == 'Single Segmentation': - continueSingle = QMessageBox.question(None,'', "You are using single segmentation option which is faster but is not advised if you want multiple regions be segmented in one image. In that case click 'Send Image' button. Do you wish to continue with single segmentation?", QMessageBox.Yes | QMessageBox.No) + continueSingle = QMessageBox.question(None,'', "You are using single segmentation option which is faster but is not advised if you want large or multiple regions be segmented in one image. In that case click 'Send Image' button. Do you wish to continue with single segmentation?", QMessageBox.Yes | QMessageBox.No) if continueSingle == QMessageBox.No: return self.singleSegmentation(serverUrl) diff --git a/server/server.py b/server/server.py old mode 100644 new mode 100755 index 9b67774..07afa5b --- a/server/server.py +++ b/server/server.py @@ -251,7 +251,7 @@ def get_image(wmin: int, wmax: int, zmin: int, zmax: int): img_1024_tensor = ( torch.tensor(img_1024).float().permute(2, 0, 1).unsqueeze(0).to(device) ) - if (zmax == -1) or (zmin <= slice_idx <= zmax): + if (zmax == -1) or ((zmin-1) <= slice_idx <= (zmax+1)): with torch.no_grad(): embedding = medsam_model.image_encoder(img_1024_tensor) # (1, 256, 64, 64) else: @@ -312,8 +312,8 @@ class InferenceParams(BaseModel): def infer(params: InferenceParams): print(params.slice_idx, params.bbox, params.zrange) zmin, zmax = params.zrange - zmax += 1 - zmin -= 1 + zmax = min(zmax+1, len(embeddings)) + zmin = max(zmin-1, 0) bbox_1024_prev = np.array([params.bbox]) / np.array([W, H, W, H]) * 256 res = {} diff --git a/server_essentials.zip b/server_essentials.zip index 0737fab..f4a8d23 100644 Binary files a/server_essentials.zip and b/server_essentials.zip differ