Skip to content

Commit 134b91d

Browse files
committed
Update Cellpose3Detector to use pixi for environment configuration
* Add a toml file for env configuration
1 parent ab4c2cf commit 134b91d

3 files changed

Lines changed: 65 additions & 16 deletions

File tree

src/main/java/org/mastodon/mamut/detection/cellpose/Cellpose3.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.annotation.Nullable;
3434

3535
import org.apposed.appose.Service;
36+
import org.mastodon.mamut.util.ResourceUtils;
3637

3738
/**
3839
* Cellpose3 is a specialized implementation of the {@link Cellpose} class, specifically
@@ -43,21 +44,11 @@ public class Cellpose3 extends Cellpose
4344
{
4445
public static final String ENV_NAME = "cellpose3";
4546

46-
public static final String ENV_FILE_CONTENT = "name: " + ENV_NAME + "\n"
47-
+ "channels:\n"
48-
+ " - nvidia\n"
49-
+ " - pytorch\n"
50-
+ " - conda-forge\n"
51-
+ "channel_priority: strict\n"
52-
+ "dependencies:\n"
53-
+ " - python=3.10\n"
54-
+ " - pip\n"
55-
+ " - pip:\n"
56-
+ " - cellpose==3.1.1.2\n"
57-
+ " - appose==" + APPOSE_PYTHON_VERSION + "\n"
58-
+ " - pytorch\n"
59-
+ " - pytorch-cuda\n"
60-
+ " - numpy\n";
47+
public static final String ENV_FILE_CONTENT =
48+
ResourceUtils.readResourceAsString( "org/mastodon/mamut/detection/cellpose/cellpose3.toml", Cellpose3.class )
49+
.replace( "{ENV_NAME}", ENV_NAME )
50+
.replace( "{APPOSE_VERSION}", APPOSE_PYTHON_VERSION );
51+
6152

6253
private final ModelType modelType;
6354

src/main/java/org/mastodon/mamut/detection/cellpose/Cellpose3Detector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected String getPythonEnvName()
179179
@Override
180180
protected Builder< ? > getBuilder()
181181
{
182-
return Appose.mamba().scheme( "environment.yml" );
182+
return Appose.pixi();
183183
}
184184

185185
@Override
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[workspace]
2+
name = "{ENV_NAME}"
3+
version = "0.0.1"
4+
description = "Cellpose3 segmentation environment."
5+
authors = ["Stefan Hahmann"]
6+
channels = ["conda-forge", "pytorch", "nvidia"]
7+
platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"]
8+
9+
[dependencies]
10+
numpy = ">=1.20,<2.1"
11+
pip = "*"
12+
13+
[pypi-dependencies]
14+
appose = "=={APPOSE_VERSION}"
15+
16+
# ---------------------------------------------------------------------------
17+
# macOS Apple Silicon
18+
# ---------------------------------------------------------------------------
19+
[target.osx-arm64.dependencies]
20+
python = "3.10.*"
21+
22+
[target.osx-arm64.pypi-dependencies]
23+
cellpose = "==3.1.1.2"
24+
torch = "==2.10.0"
25+
torchvision = "==0.25.0"
26+
27+
# ---------------------------------------------------------------------------
28+
# macOS Intel
29+
# ---------------------------------------------------------------------------
30+
[target.osx-64.dependencies]
31+
python = "3.10.*"
32+
33+
[target.osx-64.pypi-dependencies]
34+
cellpose = "==3.1.1.2"
35+
torch = "==2.1.2"
36+
torchvision = "==0.16.2"
37+
38+
# ---------------------------------------------------------------------------
39+
# Linux
40+
# ---------------------------------------------------------------------------
41+
[target.linux-64.dependencies]
42+
python = "3.11.*"
43+
pytorch = "*"
44+
pytorch-cuda = "*"
45+
46+
[target.linux-64.pypi-dependencies]
47+
cellpose = "==3.1.1.2"
48+
49+
# ---------------------------------------------------------------------------
50+
# Windows
51+
# ---------------------------------------------------------------------------
52+
[target.win-64.dependencies]
53+
python = "3.11.*"
54+
pytorch = "*"
55+
pytorch-cuda = "*"
56+
57+
[target.win-64.pypi-dependencies]
58+
cellpose = "==3.1.1.2"

0 commit comments

Comments
 (0)