1 minute read

How to Implement Comparators (Greater than, Less than, Equal to) for your Python Classes

You have written a custom python class. Here is how to implement logic to check if instances of the class are equal, less than etc.

As you build applications that get fairly large in python, you will typically have to write classes that encapsulate functions, data classes that specify data values for or interface for exchanging data etc. In many cases you will want to also check things like equality, and if how things compare. For example, consider I have a dataclass for representing docuemnts ...

Each data class is used in representing data which is also persisited to a database

But each time I createa new Document, I want to know if it already exists. Now the id is

Review TLDR;

Its pretty remarkable what has been accomplished here. Future work might benefit from:

  • Efforts to definitely would benefit from further optimizing for latency while maintaining fine grained segmentation (e.g. using residual U-blocks as proposed in the U2Net Paper. This might lead to usable FPS values on commodity CPU machines.
  • Efforts to optimize for usability by elmininating the background image requirement. E.g. by reframing the ML problem, we can train the network to jointly predict the background (image completion) in addition to the alpha matte values, and leverage this knowledge in predicting better matte values. Ideally, this formulation will utilize background images (as labels) during training but not require them during inference.

Overall, well written paper and well produced video explaining their work.

I will be updating this post as I experiment with the model itself.


Interested in more articles like this? Subscribe to get a monthly roundup of new posts and other interesting ideas at the intersection of Applied AI and HCI.

RELATED POSTS | howto, software engineering

Read the Newsletter.

I write a monthly newsletter on Applied AI and HCI. Subscribe to get notified on new posts.

Feel free to reach out! Twitter, GitHub, LinkedIn