-
Notifications
You must be signed in to change notification settings - Fork 60
PSEDiceLoss support any input shape (fix issue#333) #339
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
@@ -615,17 +603,15 @@ def __call__(self, data: dict): | |||
poly = poly.intersection(border) |
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.
use poly.is_valid before poly.intersection to avoid errors.
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.
But line594 already tested poly.is_valid: if (not poly.is_valid) or (poly.is_empty):
else: # the polygon is fully outside the image | ||
continue | ||
new_tags.append(ignore) | ||
new_texts.append(text) | ||
|
||
data['polys'] = new_polys | ||
data['polys'] = np.array(new_polys) # need to use numpy.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.
set dtype np.float32
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.
ok
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.
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.
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.
Good suggestion, reverted.
@@ -215,22 +216,24 @@ def ohem_batch(self, scores, gt_texts, training_masks): | |||
return selected_masks | |||
|
|||
def ohem_single(self, score, gt_text, training_mask): | |||
h, w = score.shape[0:2] | |||
k = int(h * w) |
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.
Not important in this case because we don't support dynamic shaping, but for the future:
during the graph construction all constants (integers, floats, etc.) will be calculated once and will not be changed during execution anymore. So, need to be careful if you intend k
to change.
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.
Ok, noted.
9cad2ba
to
f639f1c
Compare
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
Fix issue#333 and modify some codes according the comments of Rustam.
Test Plan
Already tested on CTW1500 dataset with shape (736, 736)
Related Issues and PRs
Issues: #333
PR: #290