-
Notifications
You must be signed in to change notification settings - Fork 280
Differential Binarization model #2095
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
base: master
Are you sure you want to change the base?
Conversation
output = self.image_converter( | ||
{ | ||
"images": x, | ||
"bounding_boxes": y, |
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.
I don't think we need any bounding boxes for this task.
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.
Took high level pass and left some comments.
Also,
Make al the file names in follow the same format like other files, for db_utils and losses.py
return (self.x, self.y) | ||
|
||
|
||
def shrink_polygan(polygon, offset): |
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.
shrink_polygon
class Point: | ||
def __init__(self, x, y): | ||
self.x = x | ||
self.y = y | ||
|
||
def __add__(self, other): | ||
return Point(self.x + other.x, self.y + other.y) | ||
|
||
def __sub__(self, other): | ||
return Point(self.x - other.x, self.y - other.y) | ||
|
||
def __neg__(self): | ||
return Point(-self.x, -self.y) | ||
|
||
def cross(self, other): | ||
return self.x * other.y - self.y * other.x | ||
|
||
def to_tuple(self): | ||
return (self.x, self.y) | ||
|
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.
Is there any other way you can try to achive this better without using class?
|
||
|
||
# cv2.fillpoly function with keras.ops | ||
def fill_poly_keras(vertices, image_shape): |
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.
you can just mention fill_poly
and remove the cv2 mention here and in he description and description of what this function does.
return int(height) if height >= 0.1 else 0 | ||
|
||
|
||
# project point to line |
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.
Remove all these comments, instead make the description better
high = mid | ||
|
||
height = (low + high) / 2 | ||
height = (low + high) / 2 |
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.
duplicate line
|
||
# get line of height | ||
def get_line_height(poly): | ||
return binary_search_smallest_width(poly) |
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.
You can avoid this funtion and instead call binary_search_smallest_width directly
""" | ||
Shrinks a polygon inward by moving each point toward the center. |
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.
All the docstring text should immediately follow """, change it to, and this style should be applied everywhere
"""Shrinks a polygon inward by moving each point toward the center.
@preprocessing_function | ||
def generate_postprocess(self,x): | ||
''' | ||
Generates postprocess function to convert probability map of | ||
model output to polygon | ||
''' | ||
probability_maps,threshold_maps = x["probability_maps"], x["threshold_maps"] | ||
binary_maps = 1.0 / (1.0 + keras.ops.exp(-50.0 * (probability_maps - threshold_maps))) | ||
outputs = keras.layers.Concatenate(axis=-1)( | ||
[probability_maps, threshold_maps, binary_maps]) | ||
return outputs | ||
|
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.
why do we need this? we don't have .generate
function for diff_bin right?
target_size=(640, 640), | ||
shrink_ratio=0.3, |
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.
target_size
will be image_size
and will be handled in ImageConverter
, not in this.
Where are we using this shrink_ratio
here.
Differential Binarization model.