-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bioimage-io/slim-docker-image
Slim docker image
- Loading branch information
Showing
14 changed files
with
126 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
tifffile==2024.7.24 | ||
matplotlib==3.9.0 | ||
opencv-python-headless==3.4.18.65 | ||
cellpose==3.0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-r "requirements.txt" | ||
ray[client]==2.33.0 | ||
ray[serve]==2.33.0 | ||
aiohttp==3.11.11 | ||
numpy==2.2.2 | ||
ray[client,serve]==2.33.0 | ||
segment_anything==1.0 | ||
torch==2.3.1 | ||
torchvision==0.18.1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
hypha-rpc==0.20.44 | ||
kaibu-utils==0.1.14 | ||
numpy==1.26.4 | ||
hypha-rpc==0.20.47 | ||
# kaibu-utils==0.1.14 | ||
numpy==2.2.2 | ||
python-dotenv==1.0.1 | ||
requests==2.31.0 | ||
ray[serve]==2.33.0 | ||
tifffile==2025.1.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
from hypha_rpc import connect_to_server | ||
import numpy as np | ||
import asyncio | ||
import argparse | ||
import asyncio | ||
|
||
import numpy as np | ||
from hypha_rpc import connect_to_server | ||
from tifffile import imread | ||
|
||
SERVER_URL = "https://hypha.aicell.io" | ||
WORKSPACE_NAME = "bioimageio-colab" | ||
SERVICE_ID = "microsam" | ||
SID = f"{WORKSPACE_NAME}/{SERVICE_ID}" | ||
MODEL_IDS = ["sam_vit_b", "sam_vit_b_lm", "sam_vit_b_em_organelles"] | ||
IMG_PATH = "./data/example_image.tif" | ||
|
||
|
||
async def run_client(client_id: int, image: np.ndarray): | ||
async def run_client( | ||
client_id: int, image: np.ndarray, model_id: str, method_timeout: int = 30 | ||
): | ||
print(f"Client {client_id} started", flush=True) | ||
client = await connect_to_server({"server_url": SERVER_URL, "method_timeout": 30}) | ||
segment_svc = await client.get_service(SID, {"mode": "random"}) | ||
await segment_svc.segment(model_name="vit_b", image=image, point_coordinates=[[128, 128]], point_labels=[1]) | ||
await asyncio.sleep(1) | ||
await segment_svc.segment(model_name="vit_b", image=image, point_coordinates=[[20, 50]], point_labels=[1]) | ||
await asyncio.sleep(1) | ||
await segment_svc.segment(model_name="vit_b", image=image, point_coordinates=[[180, 10]], point_labels=[1]) | ||
client = await connect_to_server( | ||
{"server_url": SERVER_URL, "method_timeout": method_timeout} | ||
) | ||
service = await client.get_service( | ||
f"{WORKSPACE_NAME}/{SERVICE_ID}", {"mode": "random"} | ||
) | ||
await service.compute_embedding(model_id=model_id, image=image) | ||
print(f"Client {client_id} finished", flush=True) | ||
|
||
|
||
async def stress_test(num_clients: int): | ||
image=np.random.rand(256, 256) | ||
image = imread(IMG_PATH) | ||
tasks = [] | ||
for client_id in range(num_clients): | ||
await asyncio.sleep(0.1) | ||
tasks.append(run_client(client_id, image)) | ||
model_id = MODEL_IDS[np.random.randint(0, len(MODEL_IDS))] | ||
tasks.append(run_client(client_id=client_id, image=image, model_id=model_id)) | ||
await asyncio.gather(*tasks) | ||
print("All clients finished") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--num_clients", type=int, default=50) | ||
args = parser.parse_args() | ||
|
||
asyncio.run(stress_test(args.num_clients)) | ||
asyncio.run(stress_test(args.num_clients)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.