Skip to content

Commit ffba37a

Browse files
authored
Merge pull request #12 from bioimage-io/ray-sam
Run SAM computations with RAY
2 parents 7a0946d + a1bffaf commit ffba37a

16 files changed

+464
-451
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ data/
1414
.DS_Store
1515
*.onnx
1616
*.pt
17+
*.pth
1718
*tif
1819
*zip
1920
visualize_annotation.py

Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@ COPY ./requirements-sam.txt /app/requirements-sam.txt
3131
RUN pip install -r /app/requirements-sam.txt
3232

3333
# Copy the python script to the docker environment
34-
COPY ./bioimageio_colab/register_sam_service.py /app/register_sam_service.py
34+
COPY ./bioimageio_colab /app/bioimageio_colab
3535

36-
# Copy the start service script
37-
COPY ./scripts/start_service.sh /app/start_service.sh
36+
# Create cache directory for models
37+
RUN mkdir -p /app/.model_cache
3838

3939
# Change ownership of the application directory to the non-root user
4040
RUN chown -R bioimageio_colab:bioimageio_colab /app/
4141

42-
# Make the start script executable
43-
RUN chmod +x /app/start_service.sh
44-
4542
# Switch to the non-root user
4643
USER bioimageio_colab
4744

4845
# Use the start script as the entrypoint and forward arguments
49-
ENTRYPOINT ["python", "register_sam_service.py"]
46+
ENTRYPOINT ["python", "-m", "bioimageio_colab"]

bioimageio_colab/__main__.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
1-
def main():
2-
print("Welcome to the bioimageio-colab")
1+
import argparse
2+
import asyncio
33

4-
if __name__ == '__main__':
5-
main()
4+
from bioimageio_colab.register_sam_service import register_service
5+
6+
if __name__ == "__main__":
7+
parser = argparse.ArgumentParser(
8+
description="Register SAM annotation service on BioImageIO Colab workspace."
9+
)
10+
parser.add_argument(
11+
"--server_url",
12+
default="https://hypha.aicell.io",
13+
help="URL of the Hypha server",
14+
)
15+
parser.add_argument(
16+
"--workspace_name", default="bioimageio-colab", help="Name of the workspace"
17+
)
18+
parser.add_argument(
19+
"--service_id",
20+
default="microsam",
21+
help="Service ID for registering the service",
22+
)
23+
parser.add_argument(
24+
"--token",
25+
default=None,
26+
help="Workspace token for connecting to the Hypha server",
27+
)
28+
parser.add_argument(
29+
"--cache_dir",
30+
default="./.model_cache",
31+
help="Directory for caching the models",
32+
)
33+
parser.add_argument(
34+
"--ray_address",
35+
default=None,
36+
help="Address of the Ray cluster for running SAM",
37+
)
38+
args = parser.parse_args()
39+
40+
loop = asyncio.get_event_loop()
41+
loop.create_task(register_service(args=args))
42+
loop.run_forever()

bioimageio_colab/bioengine_app.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

bioimageio_colab/create_workspace.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
"""
2+
Hypha now supports creating workspaces from the Hypha Dashboard. This script is no longer needed.
3+
"""
4+
15
import argparse
2-
from hypha_rpc import connect_to_server, login
36
import asyncio
47

8+
from hypha_rpc import connect_to_server, login
9+
510

611
async def create_workspace_token(args):
712
# Get a user login token
@@ -64,6 +69,7 @@ async def create_workspace_token(args):
6469
for service in services:
6570
print(f"- {service['name']}")
6671

72+
6773
if __name__ == "__main__":
6874
parser = argparse.ArgumentParser(
6975
description="Create the BioImageIO Colab workspace."

0 commit comments

Comments
 (0)