Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsmechtel committed Sep 19, 2024
1 parent 17d9195 commit 7fc10cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion bioimageio_colab/register_sam_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def segment(
def clear_cache(embedding_cache: TTLCache, context: dict = None) -> bool:
user_id = context["user"].get("id")
if user_id not in embedding_cache:
logger.info(f"User {user_id} - User not found in cache.")
return False
else:
logger.info(f"User {user_id} - Resetting embedding cache...")
Expand Down
12 changes: 4 additions & 8 deletions plugins/bioimageio-colab-annotator.imjoy.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
const serverUrl = config.server_url || "https://hypha.aicell.io";
const workspace = config.workspace;
const token = config.token;
const samServiceId = "bioimageio-colab/kubernetes/sam";
const annotationServiceId = config.annotation_service_id || `${workspace}/*:data-provider`; // default for testing plugin
const annotationServiceId = config.annotation_service_id;
if(!annotationServiceId){
await api.alert("Please provide the annotation service ID in the configuration.");
return;
}
const samServiceId = "bioimageio-colab/kubernetes:sam";

// Create and display the viewer window
const viewer = await api.createWindow({src: "https://kaibu.org/#/app", fullscreen: true});
Expand Down Expand Up @@ -118,6 +118,7 @@
// The point coordinates need to be reversed to match the coordinate convention of SAM
const pointCoords = [shape.geometry.coordinates.reverse()];
const pointLabels = pointCoords.map(() => 1); // All points have a label of 1
let features = [];

// Compute embeddings if not already computed for the image
try {
Expand All @@ -126,12 +127,7 @@
} else {
await api.showMessage("Segmenting...");
}
const features = await samService.segment(
model_name=this.modelName,
image=this.image,
point_coordinates=pointCoords,
point_labels=pointLabels
);
features = await samService.segment(this.modelName, this.image, pointCoords, pointLabels);
embeddingIsCalculated = true;
} catch (e) {
await api.showMessage(`Failed to compute the image embedding. (Error: ${e})`);
Expand Down

0 comments on commit 7fc10cc

Please sign in to comment.