-
Notifications
You must be signed in to change notification settings - Fork 8k
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
fix dataset problems release 2.7 #11646
base: release/2.7
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,9 @@ def maybe_download_params(model_path): | |
else: | ||
url = model_path | ||
tmp_path = os.path.join(MODELS_DIR, url.split('/')[-1]) | ||
if os.path.exists(tmp_path) and os.path.isfile(tmp_path): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be deleted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi models from Model_Path was downloaded to tmp_path but it is repeated to do so each time when we launch a task in the same machine, which takes about 3-5 minutes. This is unnecessary. A better way I think is, by providing MD5 sum in model configuration file, we can check if the files in tmp_path is correct. But any change to the config in this project requires work checking all the other configuration files. That will be too cumbersome. |
||
print(f'[network::maybe_download_params] models has been downloaded to {tmp_path}') | ||
return tmp_path | ||
print('download {} to {}'.format(url, tmp_path)) | ||
os.makedirs(MODELS_DIR, exist_ok=True) | ||
download_with_progressbar(url, tmp_path) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import random | ||
from ppocr.utils.logging import get_logger | ||
|
||
from shapely.geometry import Polygon | ||
|
||
def str2bool(v): | ||
return v.lower() in ("true", "yes", "t", "y", "1") | ||
|
@@ -609,8 +610,31 @@ def get_rotate_crop_image(img, points): | |
img_crop = img[top:bottom, left:right, :].copy() | ||
points[:, 0] = points[:, 0] - left | ||
points[:, 1] = points[:, 1] - top | ||
''' | ||
assert len(points) == 4, "shape of points must be 4*2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Situations where more data formats need to be processed in addition to CTW There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. But both in CTW, ICDAR2015 and our own annotation files we don't assume bbox consists of fixed number number of points to form a valid bbox polyline. So we just treat it as general polyline: 2 points (upper left, bottom right), 3 points (trianguulars), and closed polylines |
||
''' | ||
if not isinstance(points, np.ndarray): | ||
raise Exception("polygons must be of shape numpy array!") | ||
rank = len(points.shape) | ||
if rank != 2: | ||
points = points.reshape(-1, 2) | ||
# capture bbox of points, the length of points must be > 1 | ||
assert len(points) > 1 and len(points) % 2 == 0, "[utility::get_rotate_crop_image] shape of points must be greater than 1 and labeled with even points" | ||
x_min, y_min = np.min(points, axis=0) | ||
x_max, y_max = np.max(points, axis=0) | ||
|
||
points_ = points | ||
points = np.array([ | ||
[x_min, y_min], | ||
[x_max, y_min], | ||
[x_max, y_max], | ||
[x_min, y_max] | ||
], dtype=points_.dtype) | ||
|
||
area = Polygon(points).area | ||
assert area > 1, "[utility::get_rotate_crop_image] bbox must has area greater than 1 pixel unit" | ||
|
||
# TODO (yiakwy) : remove this unwanted check, since CWT dataset | ||
# naturally contains points more than 4 | ||
# assert len(points) == 4, "shape of points must be 4*2" | ||
img_crop_width = int( | ||
max( | ||
np.linalg.norm(points[0] - points[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.
need to handle this situation
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.
Hi, this is where we need to discuss.
This condition leaded to endless loop and discarded every annotation line with points more than 4 in detection task.
I have checked annotation files we generated and official dataset from ctw1500 (800M) and ICDAR2015 (80M) datasets which are used for finetuning and evaluation: they both have annotation lines with more than 4 points.
The root cause is utility file can only process polygon with fixed points:
Hence we deleted the unnecessary constrain (4 points bbox annotation is just a simple case of general closed polyline) and training goes smoothly again.