-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add Rename Classes UQL Operation #656
Conversation
@PawelPeczek-Roboflow let me know if you have any feedback any here from our convo today. |
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.
There is one issue with potential collapse of class id:
original detections have 1-1 relationship between class name and class id, after mapping this is not guaranteed.
Additional difficulty is also keeping original class.
Maintaining classes ids may be important - for instance to have visualisation that works consistently (look how this is implemented in supervision
)
Proposed solution:
- enforce full mapping - if not given raise operation error
- when classes collapse - keep lower class id
if for some reason we wish to let non-strict class mappings, I suggest adding operation parameter (strict: bool
with default True
), such that people take risk by willingly declaring so.
@@ -28,6 +28,11 @@ def red_image() -> np.ndarray: | |||
return cv2.imread(os.path.join(ASSETS_DIR, "red_image.png")) | |||
|
|||
|
|||
@pytest.fixture(scope="function") | |||
def fruit_image() -> np.ndarray: | |||
return cv2.imread(os.path.join(ASSETS_DIR, "multi-fruit.jpg")) |
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.
please report image credits
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.
Complete
@@ -0,0 +1,124 @@ | |||
import numpy as np |
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.
great tests coverage
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.
@PawelPeczek-Roboflow Hey Pawel, I couldn't figure out or find a good example of passing Input Parameters into UQL operations for tests. Instead I created a hacky work around with parameterized tests to replace the Workflow Specification to test scenarios. Feel free to change this if you'd like; as I would also like to learn how to pass input parameters into UQL operations for future work.
@NickHerrig planning release tmrw - would u be able to apply changes? if not I can help, but let's agree on what we do with doubts I raised |
@PawelPeczek-Roboflow yes I have time now to complete these changes. I agree with your proposed solution to avoid same class names having different class-id(collapse) causing variability in annotation color, etc. |
ok, great |
@PawelPeczek-Roboflow I implemented most of your propsal, with one slight addition to handle the case of assigning new class_ids when a class name does not exist in the original detections.
Feel free to make changes if you see a problem with this approach. |
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.
Added additional params to avoid collisions, tested and refactored the code to avoid O(n^2) complexity
@hansent @EmilyGavrilenko - this would need to be implemented on UI end: #656 |
Thanks for your help @PawelPeczek-Roboflow getting this across the line! |
Description
This PR adds UQL operation to handle renaming of classes given a
class_map
.Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?