Skip to content

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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mehtamansi29
Copy link
Collaborator

@mehtamansi29 mehtamansi29 commented Feb 12, 2025

Differential Binarization model.

output = self.image_converter(
{
"images": x,
"bounding_boxes": y,
Copy link
Collaborator

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.

@sachinprasadhs sachinprasadhs added the WIP Pull requests which are work in progress and not ready yet for review. label Apr 11, 2025
Copy link
Collaborator

@sachinprasadhs sachinprasadhs left a 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):
Copy link
Collaborator

Choose a reason for hiding this comment

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

shrink_polygon

Comment on lines +4 to +23
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)

Copy link
Collaborator

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

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

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

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

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

Comment on lines +26 to +27
"""
Shrinks a polygon inward by moving each point toward the center.
Copy link
Collaborator

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.

Comment on lines +45 to +56
@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

Copy link
Collaborator

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?

Comment on lines +17 to +18
target_size=(640, 640),
shrink_ratio=0.3,
Copy link
Collaborator

@sachinprasadhs sachinprasadhs May 15, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Pull requests which are work in progress and not ready yet for review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants