Skip to content

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

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

VictorHe-1
Copy link
Collaborator

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

@@ -615,17 +603,15 @@ def __call__(self, data: dict):
poly = poly.intersection(border)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set dtype np.float32

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, but ci failed with this 😥
截屏2023-06-02 10 43 23

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because clipping polygons may result in different number of vertices. The new pipeline for ValidatePolygons is in PR #292. You can revert your changes in ValidatePolygons to avoid conflict with #292.

Copy link
Collaborator Author

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)
Copy link
Collaborator

@hadipash hadipash Jun 2, 2023

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, noted.

@VictorHe-1 VictorHe-1 force-pushed the predict branch 2 times, most recently from 9cad2ba to f639f1c Compare June 2, 2023 02:44
@liangxhao liangxhao merged commit eec3d56 into mindspore-lab:main Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants