Skip to content

Commit a083d5c

Browse files
committed
Migrate Cellpose3 environment to pixi TOML and load via ResourceUtils
1 parent c41bfae commit a083d5c

2 files changed

Lines changed: 58 additions & 15 deletions

File tree

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

Lines changed: 5 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,10 @@ 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 );
6151

6252
private final ModelType modelType;
6353

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[workspace]
2+
name = 'cellpose3'
3+
version = '0.0.1'
4+
description = 'Mastodon spot detector using Cellpose 3.'
5+
authors = ['Stefan Hahmann']
6+
channels = ['conda-forge']
7+
platforms = ['osx-arm64', 'osx-64', 'linux-64', 'win-64']
8+
9+
# Assume CUDA 12 is available when solving for platforms that use it (linux-64,
10+
# win-64). On platforms without CUDA (macOS), pixi silently ignores this at
11+
# runtime.
12+
[system-requirements]
13+
cuda = '12'
14+
15+
[dependencies]
16+
python = '==3.10'
17+
numpy = '*'
18+
pip = '*'
19+
20+
[pypi-dependencies]
21+
appose = '==0.7.2'
22+
cellpose = '==3.1.1.2'
23+
24+
# ---------------------------------------------------------------------------
25+
# WINDOWS (GPU PyTorch by default)
26+
# ---------------------------------------------------------------------------
27+
28+
[target.win-64.dependencies]
29+
pytorch-gpu = '*'
30+
31+
# ---------------------------------------------------------------------------
32+
# LINUX (GPU PyTorch by default)
33+
# ---------------------------------------------------------------------------
34+
35+
[target.linux-64.dependencies]
36+
pytorch-gpu = '*'
37+
38+
# ---------------------------------------------------------------------------
39+
# macOS INTEL (CPU PyTorch)
40+
# ---------------------------------------------------------------------------
41+
42+
[target.osx-64.dependencies]
43+
pytorch = '*'
44+
45+
# ---------------------------------------------------------------------------
46+
# macOS Apple Silicon (MPS via PyTorch)
47+
# ---------------------------------------------------------------------------
48+
49+
[target.osx-arm64.dependencies]
50+
pytorch = '*'
51+
52+
[environments]
53+
default = { solve-group = 'default' }

0 commit comments

Comments
 (0)