Skip to content

Commit

Permalink
Boundary selection bug and peogress check setup fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rasakereh committed Mar 11, 2024
1 parent b066e0e commit 27482d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions MedSAM/MedSAMLite/MedSAMLite.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions server/server.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = {}

Expand Down
Binary file modified server_essentials.zip
Binary file not shown.

0 comments on commit 27482d8

Please sign in to comment.