Skip to content

Commit

Permalink
made raw mask generation mode to predict the same class
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxTeselkin committed Dec 16, 2024
1 parent 0adde98 commit 4148be0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
10 changes: 5 additions & 5 deletions supervisely_integration/serve/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"community_agent": false,
"docker_image": "supervisely/segment-anything-hq:1.0.5",
"instance_version": "6.7.33",
"instance_version": "6.9.22",
"entrypoint": "python -m uvicorn main:model.app --app-dir ./supervisely_integration/serve/src --host 0.0.0.0 --port 8000 --ws websockets",
"port": 8000,
"task_location": "application_sessions",
Expand All @@ -29,8 +29,8 @@
},
"access_restriction": [
{
"instance": "community_free",
"message": "The best interactive models for AI-assisted segmentation are already deployed in the Supervisely Cloud and are available for auto-labeling to all platform users. The number of API calls and the ability to run this app on your own agent (GPU) are limited for Free accounts. To increase usage limits or run the app on your GPU, switch to the <a href=\"/billing\">Pro</a> plan or request the <a href=\"https://supervisely.com/contact-us/\" target=\"_blank\">Enterprise</a> Edition."
"instance": "community_free",
"message": "The best interactive models for AI-assisted segmentation are already deployed in the Supervisely Cloud and are available for auto-labeling to all platform users. The number of API calls and the ability to run this app on your own agent (GPU) are limited for Free accounts. To increase usage limits or run the app on your GPU, switch to the <a href=\"/billing\">Pro</a> plan or request the <a href=\"https://supervisely.com/contact-us/\" target=\"_blank\">Enterprise</a> Edition."
}
]
}
]
}
14 changes: 3 additions & 11 deletions supervisely_integration/serve/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def load_on_device(
# build predictor
self.predictor = SamPredictor(self.sam)
# define class names
self.class_names = ["target_mask"]
self.class_names = ["object_mask"]
# list for storing mask colors
self.mask_colors = [[255, 0, 0]]
# variable for storing image ids from previous inference iterations
Expand Down Expand Up @@ -180,18 +180,10 @@ def predict(self, image_path: str, settings: Dict[str, Any]) -> List[sly.nn.Pred
output_mode=settings["output_mode"],
)
masks = mask_generator.generate(input_image)
for i, mask in enumerate(masks):
class_name = "object_" + str(i)
# add new class to model meta if necessary
if not self._model_meta.get_obj_class(class_name):
color = generate_rgb(self.mask_colors)
self.mask_colors.append(color)
self.class_names.append(class_name)
new_class = sly.ObjClass(class_name, sly.Bitmap, color)
self._model_meta = self._model_meta.add_obj_class(new_class)
for mask in masks:
# get predicted mask
mask = mask["segmentation"]
predictions.append(sly.nn.PredictionMask(class_name=class_name, mask=mask))
predictions.append(sly.nn.PredictionMask(class_name="object_mask", mask=mask))
elif settings["mode"] == "bbox":
# get bbox coordinates
if "rectangle" not in settings:
Expand Down

0 comments on commit 4148be0

Please sign in to comment.