-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code for better modularity and add new features
Deleted the primitives.py and postprocessing.text.py files along with their corresponding tests as their functionalities have been refactored. parse_mark_id method from the deleted files have been moved to sam_segmentation.py which is a simplified version of the extract_marks_in_brackets method and is more suitable for the task at hand. extract_relevant_masks has been replaced by a process method in SamResponseProcessor which extracts the relevant mark ids from the text and uses them to index the detections object. The mark generating classes have been moved to the wrappers directory as they are effectively serving as wrappers around existing models. Made these changes to make the classes more modular, easy to understand and use. They can be extended in the future to include more models other than SAM. Also, created two new abstract base classes BasePromptCreator and BaseResponseProcessor in base.py file under pipelines directory. These two classes would be used to ensure a consistent structure across different pipelines. In maestro/__init__.py, SegmentAnythingMarkGenerator was renamed to SegmentAnything to adhere to the new structure. Bumped the version of Maestro to 0.2.0rc1 from 0.1.1rc1 reflecting the amount of changes made. Finally, updated README.md to reflect the changes made to the API but the new API usage example still needs to be added.
- Loading branch information
Showing
12 changed files
with
81 additions
and
183 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
from abc import ABC | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class BasePromptCreator(ABC): | ||
pass | ||
|
||
@abstractmethod | ||
def create(self, *args, **kwargs): | ||
pass | ||
|
||
|
||
class BaseResponseProcessor(ABC): | ||
pass | ||
|
||
@abstractmethod | ||
def process(self, *args, **kwargs): | ||
pass |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 @@ | ||
[tool.poetry] | ||
name = "maestro" | ||
version = "0.1.1rc1" | ||
version = "0.2.0rc1" | ||
description = "Visual Prompting for Large Multimodal Models (LMMs)" | ||
authors = ["Piotr Skalski <[email protected]>"] | ||
maintainers = ["Piotr Skalski <[email protected]>"] | ||
|
@@ -34,7 +34,7 @@ classifiers=[ | |
|
||
[tool.poetry.dependencies] | ||
python = ">=3.8,<3.12.0" | ||
supervision = "^0.17.0rc4" | ||
supervision = "^0.17.0rc6" | ||
requests = "^2.31.0" | ||
transformers = "^4.35.2" | ||
|
||
|
Empty file.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import List | ||
|
||
import pytest | ||
|
||
from maestro.pipelines.sam_segmentation import extract_mark_ids | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"text, expected_result", | ||
[ | ||
("[1]", ["1"]), | ||
("lorem ipsum [1] dolor sit amet", ["1"]), | ||
("[1] lorem ipsum [2] dolor sit amet", ["1", "2"]), | ||
("[1] lorem ipsum [1] dolor sit amet", ["1"]), | ||
("[2] lorem ipsum [1] dolor sit amet", ["1", "2"]) | ||
] | ||
) | ||
def test_extract_marks_in_brackets(text: str, expected_result: List[str]) -> None: | ||
result = extract_mark_ids(text=text) | ||
assert result == expected_result |
This file was deleted.
Oops, something went wrong.