-
Notifications
You must be signed in to change notification settings - Fork 61
Refactor evaluation flow #309
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's high recommended to add a unit test for DetBasePostprocessing as it is a common API, to ensure it works as expected in different settings.
if isinstance(sample, np.ndarray): | ||
result = np.round(sample * shape[:1:-1]) | ||
else: | ||
result = [np.round(s * shape[:1:-1]) for s in sample] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shape[:1:-1]) --> shape[::-1]. otherwise, it will be wrong if scale_h, and scale_w are different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the shape
's values are [h, w, scale_h, scale_w]
. shape[:1:-1]
takes the last 2 values (which are scale_h
and scale_w
) and reverse them to match x, y order of data.
self._scale_fields = rescale_fields | ||
|
||
@staticmethod | ||
def _scale_sample(sample: Union[List[np.ndarray], np.ndarray], shape: np.ndarray): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name sample
is easy to get confuse with data sample. but the input here are polygons, curves, or boxes for text region representation. replacing sample
with field
or result
will be intuitive, e.g., _rescale_result(...)
def _scale_sample(sample: Union[List[np.ndarray], np.ndarray], shape: np.ndarray): | ||
# shape: [h, w, scale_h, scale_w] | ||
if isinstance(sample, np.ndarray): | ||
result = np.round(sample * shape[:1:-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either we np.clip the rounded coordinates in origin_width, orgin_height to avoid being out of the image. Or we don't clip and still keep float type here, then np.clip all at one in the end.
related to this pr: #316 |
import cv2 | ||
import numpy as np | ||
from shapely.geometry import Polygon | ||
import mindspore as ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line#236 and Line#242 need this import.
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
det_postprocess.py
to match the project's default data handling flow.