Skip to content

Commit fae2679

Browse files
Merge branch 'main' of https://github.com/mouseland/cellpose into main
2 parents b552081 + 3864748 commit fae2679

24 files changed

+3767
-138
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Run log**
21+
Please post all command line/notebook output for us to understand the problem. For this please make sure you are running with verbose mode on. So command line, with `--verbose` tag, or in a notebook first run
22+
```from cellpose import io
23+
logger = io.logger_setup()
24+
```
25+
before running any Cellpose functions.
26+
27+
**Screenshots**
28+
If applicable, add screenshots to help explain your problem.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE]"
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Installation issue
3+
about: problems installing cellpose with or without GPU support
4+
title: "[INSTALL]"
5+
labels: install
6+
assignees: ''
7+
8+
---
9+
10+
**Install problem**
11+
Let us know what issues you are having with installation.
12+
13+
**Environment info**
14+
Please run `conda list` in your cellpose environment in the terminal / anaconda prompt to let us know your software versions.
15+
16+
**Run log**
17+
Please post all command line/notebook output for us to understand the problem. For this please make sure you are running with verbose mode on. So command line, with `--verbose` tag, or in a notebook first run
18+
19+
```from cellpose import io
20+
logger = io.logger_setup()
21+
```
22+
23+
before running any Cellpose functions.

cellpose/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
Welcome to CellposeSAM, cellpose v4.0.1! The neural network component of
44
CPSAM is much larger than in previous versions and CPU excution is slow.
55
We encourage users to use GPU/MPS if available. \n\n'''
6-
print(message)
6+
print(message)

cellpose/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def run_net(net, imgi, batch_size=8, augment=False, tile_overlap=0.1, bsize=224,
218218
# pad image for net so Ly and Lx are divisible by 4
219219
imgb = transforms.resize_image(imgi[b], rsz=rsz) if rsz is not None else imgi[b].copy()
220220
imgb = np.pad(imgb.transpose(2,0,1), pads, mode="constant")
221-
IMG, ysub, xsub, Ly, Lx = transforms.make_tiles(
221+
IMG, ysub, xsub, Lyt, Lxt = transforms.make_tiles(
222222
imgb, bsize=bsize, augment=augment,
223223
tile_overlap=tile_overlap)
224224
IMGa[i * ntiles : (i+1) * ntiles] = np.reshape(IMG,
@@ -245,7 +245,7 @@ def run_net(net, imgi, batch_size=8, augment=False, tile_overlap=0.1, bsize=224,
245245
y = np.reshape(y, (ny, nx, 3, ly, lx))
246246
y = transforms.unaugment_tiles(y)
247247
y = np.reshape(y, (-1, 3, ly, lx))
248-
yfi = transforms.average_tiles(y, ysub, xsub, Ly, Lx)
248+
yfi = transforms.average_tiles(y, ysub, xsub, Lyt, Lxt)
249249
yf[b] = yfi[:, :imgb.shape[-2], :imgb.shape[-1]]
250250
stylei = stylea[i * ntiles:(i + 1) * ntiles].sum(axis=0)
251251
stylei /= (stylei**2).sum()**0.5

cellpose/dynamics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ def max_pool_nd(h, kernel_size=5):
486486
del hmax2
487487
return hmax
488488

489-
490489
def get_masks_torch(pt, inds, shape0, rpad=20, max_size_fraction=0.4):
491490
"""Create masks using pixel convergence after running dynamics.
492491
@@ -690,4 +689,4 @@ def compute_masks(dP, cellprob, p=None, niter=200, cellprob_threshold=0.0,
690689
dynamics_logger.warning(
691690
"more than 65535 masks in image, masks returned as np.uint32")
692691

693-
return mask
692+
return mask

cellpose/gui/gui.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import cv2
1717

1818
from . import guiparts, menus, io
19-
from .. import models, core, dynamics, version, denoise, train
19+
from .. import models, core, dynamics, version, train
2020
from ..utils import download_url_to_file, masks_to_outlines, diameters
2121
from ..io import get_image_files, imsave, imread
2222
from ..transforms import resize_image, normalize99, normalize99_tile, smooth_sharpen_img
@@ -29,14 +29,6 @@
2929
except:
3030
MATPLOTLIB = False
3131

32-
try:
33-
from google.cloud import storage
34-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.path.join(
35-
os.path.dirname(os.path.realpath(__file__)), "key/cellpose-data-writer.json")
36-
SERVER_UPLOAD = True
37-
except:
38-
SERVER_UPLOAD = False
39-
4032
Horizontal = QtCore.Qt.Orientation.Horizontal
4133

4234

@@ -174,7 +166,6 @@ def run(image=None):
174166
app.setWindowIcon(app_icon)
175167
app.setStyle("Fusion")
176168
app.setPalette(guiparts.DarkPalette())
177-
178169
MainW(image=image, logger=logger)
179170
ret = app.exec_()
180171
sys.exit(ret)
@@ -187,7 +178,7 @@ def __init__(self, image=None, logger=None):
187178

188179
self.logger = logger
189180
pg.setConfigOptions(imageAxisOrder="row-major")
190-
self.setGeometry(50, 50, 2000, 1500)
181+
self.setGeometry(50, 50, 1200, 1000)
191182
self.setWindowTitle(f"cellpose v{version}")
192183
self.cp_path = os.path.dirname(os.path.realpath(__file__))
193184
app_icon = QtGui.QIcon()
@@ -764,7 +755,6 @@ def model_choose(self, custom=False):
764755
print(f"GUI_INFO: selected model {model_name}, loading now")
765756
self.initialize_model(model_name=model_name, custom=custom)
766757

767-
768758
def toggle_scale(self):
769759
if self.scale_on:
770760
self.p0.removeItem(self.scale)
@@ -1604,7 +1594,6 @@ def draw_layer(self):
16041594
self.outcolor).astype(np.uint8)
16051595

16061596

1607-
16081597
def set_normalize_params(self, normalize_params):
16091598
from cellpose.models import normalize_default
16101599
if self.restore != "filter":
@@ -1760,13 +1749,10 @@ def get_model_path(self, custom=False):
17601749
self.current_model_path = os.fspath(
17611750
models.MODEL_DIR.joinpath(self.current_model))
17621751
else:
1763-
self.current_model = self.net_names[max(
1764-
0,
1765-
self.ModelChooseB.currentIndex() - 1)]
1752+
self.current_model = "cpsam"
17661753
self.current_model_path = models.model_path(self.current_model)
17671754

17681755
def initialize_model(self, model_name=None, custom=False):
1769-
print(model_name, custom)
17701756
if model_name is None or custom:
17711757
self.get_model_path(custom=custom)
17721758
if not os.path.exists(self.current_model_path):

cellpose/gui/guiparts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def __init__(self, parent, model_name, text):
143143
self.setText(text)
144144
self.setFont(parent.boldfont)
145145
self.clicked.connect(lambda: self.press(parent))
146-
self.model_name = model_name if "cyto3" not in model_name else "cyto3"
146+
self.model_name = "cpsam"
147147

148148
def press(self, parent):
149-
parent.compute_segmentation(model_name=self.model_name)
149+
parent.compute_segmentation(model_name="cpsam")
150150

151151

152152
class FilterButton(QPushButton):

cellpose/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,4 @@ def _compute_masks(self, shape, dP, cellprob, flow_threshold=0.4, cellprob_thres
470470
if shape[0] > 1:
471471
models_logger.info("masks created in %2.2fs" % (flow_time))
472472

473-
return masks
473+
return masks

conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def image_names_3d():
2020

2121

2222
def extract_zip(cached_file, url, data_path):
23-
utils.download_url_to_file(url, cached_file)
24-
with zipfile.ZipFile(cached_file,"r") as zip_ref:
25-
zip_ref.extractall(data_path)
26-
23+
if not cached_file.exists():
24+
utils.download_url_to_file(url, cached_file)
25+
with zipfile.ZipFile(cached_file,"r") as zip_ref:
26+
zip_ref.extractall(data_path)
2727

2828
@pytest.fixture()
2929
def data_dir(image_names):
@@ -96,4 +96,4 @@ def eval(self, x, **kwargs):
9696
toc = time.time()
9797

9898
print(f'eval() time elapsed: {toc-tic}')
99-
return res
99+
return res

0 commit comments

Comments
 (0)