I'm not a huge fan of having so many self.instance things but don't see a great alterative...
(self, validate_label_file = True)
| 1741 | 'to_ref': to_ref}) |
| 1742 | |
| 1743 | def instance_limits(self, validate_label_file = True): |
| 1744 | """ |
| 1745 | I'm not a huge fan of having so many self.instance things |
| 1746 | but don't see a great alterative... |
| 1747 | """ |
| 1748 | # Initialize default Values |
| 1749 | self.instance.points = {'points': []} |
| 1750 | |
| 1751 | if validate_label_file: |
| 1752 | if self.validate_label_file_id() is False: |
| 1753 | return False |
| 1754 | |
| 1755 | # Any other "prep" work for files? |
| 1756 | if self.instance.type == "box": |
| 1757 | assert self.instance.x_min is not None |
| 1758 | |
| 1759 | if self.instance.type in ["polygon", "point", "line"]: |
| 1760 | |
| 1761 | spec_list = [{'points': { |
| 1762 | 'default': None, |
| 1763 | 'kind': list, |
| 1764 | 'required': True, |
| 1765 | 'empty': False |
| 1766 | } |
| 1767 | }] |
| 1768 | |
| 1769 | self.log, input = regular_input.input_check_many( |
| 1770 | spec_list = spec_list, |
| 1771 | log = self.log, |
| 1772 | untrusted_input = self.instance_proposed) |
| 1773 | |
| 1774 | if len(self.log["error"].keys()) >= 1: |
| 1775 | return False |
| 1776 | |
| 1777 | self.instance.points = {'points': input['points']} # Due to dict storing funnyness |
| 1778 | |
| 1779 | # this assert is kinda silly now that we are running this right here... |
| 1780 | assert self.instance.points is not None |
| 1781 | |
| 1782 | result = self.check_polygon_points_and_build_bounds() |
| 1783 | if result is False: return |
| 1784 | |
| 1785 | if self.instance.type in ["box", "polygon"]: |
| 1786 | |
| 1787 | # TODO clarify when exactly "rounding" is needed here |
| 1788 | # Maybe have been for polygon thing or something?? |
| 1789 | self.instance.x_min = round(self.instance.x_min) |
| 1790 | self.instance.y_min = round(self.instance.y_min) |
| 1791 | self.instance.y_max = round(self.instance.y_max) |
| 1792 | self.instance.x_max = round(self.instance.x_max) |
| 1793 | |
| 1794 | self.instance.x_min = max(0, self.instance.x_min) |
| 1795 | self.instance.y_min = max(0, self.instance.y_min) |
| 1796 | |
| 1797 | # How do we want to handle the "max" value |
| 1798 | # We can use file.image.width / file.image.height |
| 1799 | # But don't really want to have to make an extra hop for every save. |
| 1800 | # May want this as some kind of optional thing like |
no test coverage detected