-
Notifications
You must be signed in to change notification settings - Fork 15
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 #55 from aalto-ui/feat/segmentation
feat(metric, segmentation): segmentation and grid metrics
- Loading branch information
Showing
88 changed files
with
12,146 additions
and
873 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,16 +42,17 @@ | |
) | ||
from aim.exceptions import ValidationError | ||
from aim.models import MessageBase, MessageImage, MessageInput, MessageURL | ||
from aim.segmentation.model import Segmentation | ||
from aim.tools import Screenshot | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Metadata | ||
# ---------------------------------------------------------------------------- | ||
|
||
__author__ = "Markku Laine" | ||
__date__ = "2022-04-25" | ||
__date__ = "2022-12-20" | ||
__email__ = "[email protected]" | ||
__version__ = "1.1" | ||
__version__ = "1.2" | ||
|
||
|
||
# ---------------------------------------------------------------------------- | ||
|
@@ -147,6 +148,21 @@ def on_message(self, message: Union[str, bytes]): | |
} | ||
) | ||
|
||
# Execute segmentation | ||
# Check if segmentation is needed | ||
metrics_configurations: Dict[ | ||
str, Any | ||
] = utils.load_metrics_configurations() | ||
metrics_conf_segmentation: List = [ | ||
metrics_configurations["metrics"][metric][ | ||
"segmentation_required" | ||
] | ||
for metric in msg.metrics.keys() | ||
] | ||
gui_segments: Optional[Dict[str, Any]] = None | ||
if any(metrics_conf_segmentation): | ||
gui_segments = Segmentation.execute(png_image_base64) | ||
|
||
# Iterate over selected metrics and execute them one by one | ||
for metric in {k: v for k, v in msg.metrics.items()}: | ||
logger.debug("Executing metric {}...".format(metric)) | ||
|
@@ -176,6 +192,7 @@ def on_message(self, message: Union[str, bytes]): | |
results: Optional[List[Union[int, float, str]]] = metric_module.Metric.execute_metric( # type: ignore | ||
png_image_base64, | ||
gui_type=GUI_TYPE_DESKTOP, | ||
gui_segments=gui_segments, | ||
gui_url=msg.url, | ||
) | ||
end_time: float = time.time() | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
# Standard library modules | ||
import abc | ||
from typing import Any, List, Optional, Union | ||
from typing import Any, Dict, List, Optional, Union | ||
|
||
# Third-party modules | ||
from pydantic import HttpUrl | ||
|
@@ -25,9 +25,9 @@ | |
# ---------------------------------------------------------------------------- | ||
|
||
__author__ = "Markku Laine" | ||
__date__ = "2022-05-26" | ||
__date__ = "2022-12-20" | ||
__email__ = "[email protected]" | ||
__version__ = "1.1" | ||
__version__ = "1.2" | ||
|
||
|
||
# ---------------------------------------------------------------------------- | ||
|
@@ -51,6 +51,7 @@ def execute_metric( | |
self, | ||
gui_image: str, | ||
gui_type: int = GUI_TYPE_DESKTOP, | ||
gui_segments: Optional[Dict[str, Any]] = None, | ||
gui_url: Optional[HttpUrl] = None, | ||
) -> Optional[List[Union[int, float, str]]]: | ||
""" | ||
|
@@ -61,6 +62,7 @@ def execute_metric( | |
Kwargs: | ||
gui_type: GUI type, desktop = 0 (default), mobile = 1 | ||
gui_segments: GUI segments (defaults to None) | ||
gui_url: GUI URL (defaults to None) | ||
Returns: | ||
|
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
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
Oops, something went wrong.