Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor bugs #5

Merged
merged 1 commit into from Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -7,7 +7,7 @@ This repository contains a Prodigy plugin for recipes that involve Metas [Segmen
You can install this plugin via `pip`.

```
pip install "prodigy-ann @ git+https://github.com/explosion/prodigy-segment"
pip install "prodigy-segment @ git+https://github.com/explosion/prodigy-segment"
```

To learn more about this plugin, you can check the [Prodigy docs](https://prodi.gy/docs/plugins/#segment).
Expand Down
5 changes: 3 additions & 2 deletions prodigy_segment/__init__.py
Expand Up @@ -14,7 +14,7 @@
from prodigy.types import LabelsType, SourceType, TaskType
from prodigy.util import log, msg
from prodigy_segment.segment_anything import sam_model_registry, SamPredictor

from typing import Dict, Union

HTML = """
<link
Expand Down Expand Up @@ -125,12 +125,13 @@ def calculate_masks(box_coordinates: List, predictor: SamPredictor, pil_image: I
return masks


def get_base64_string(img_str: str):
def get_base64_string(img: Union[Dict[str, str], str]):
# This looks hacky at first glance, but the reasoning here is that the schema
# per https://en.wikipedia.org/wiki/Data_URI_scheme#Syntax looks like this:
# data:[<media type>][;charset=<character set>][;base64],<data>
# The encoding will always end with base64, so that's the easy place to cut.
# Otherwise we risk assuming a media type or characterset.
img_str = img["image"] if isinstance(img, dict) else img
str_idx = img_str.find("base64,") + 7
return img_str[str_idx:]

Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Expand Up @@ -21,8 +21,7 @@ install_requires =
[options.entry_points]
prodigy_recipes =
segment.image.manual = prodigy_segment:segment_image_manual
segment.cache = prodigy_segment:segment_cache

segment.cache = prodigy_segment:segment_fill_cache
[bdist_wheel]
universal = true

Expand Down