-
Notifications
You must be signed in to change notification settings - Fork 7
Simplify Image class to pure NumPy #1161
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
Open
leshy
wants to merge
3
commits into
dev
Choose a base branch
from
refactor/simplify-image
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+315
−3,044
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Greptile OverviewGreptile SummaryConsolidated the Image class from a multi-backend wrapper architecture (supporting both CUDA/CuPy and NumPy backends) into a simple pure-NumPy dataclass implementation. Key Changes
Migration PathThe changes maintain backward compatibility by:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Image
participant NumPy
participant OpenCV
participant TurboJPEG
Note over Image: Before: Multi-backend (CudaImage/NumpyImage)
Note over Image: After: Pure NumPy dataclass
User->>Image: from_numpy(np_array)
Image->>NumPy: np.asarray(data)
Image-->>User: Image instance
User->>Image: from_file(path)
Image->>OpenCV: cv2.imread()
OpenCV-->>Image: numpy array
Image-->>User: Image instance
User->>Image: to_rgb() / to_bgr()
Image->>OpenCV: cv2.cvtColor()
OpenCV-->>Image: converted array
Image-->>User: new Image
User->>Image: lcm_jpeg_encode()
Image->>Image: to_bgr()
Image->>TurboJPEG: encode(bgr_data)
TurboJPEG-->>Image: jpeg bytes
Image-->>User: LCM encoded bytes
User->>Image: lcm_jpeg_decode(bytes)
Image->>TurboJPEG: decode(jpeg_data)
TurboJPEG-->>Image: bgr array
Image-->>User: Image instance
Note over Image: All data stored as np.ndarray
Note over Image: No CUDA/CuPy backend
|
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.
5 files reviewed, no comments
216b060 to
e97da39
Compare
- Rewrite Image.py as a simple dataclass with NumPy-only data - Delete image_impls/ directory (AbstractImage, CudaImage, NumpyImage) - Remove unused methods (solve_pnp, csrt_tracker, from_depth, to_depth_meters) - Update all imports across codebase - Simplify rectify_image to CPU-only path
e97da39 to
c8c564c
Compare
Fixes mypy no-any-return error by fully typing the ndarray as np.ndarray[Any, np.dtype[Any]] instead of suppressing with type ignore.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove CUDA/CuPy backend and consolidate Image into a simple dataclass with NumPy-only data storage.
This CUDA backend was always strictly slower and implementation was horrible and made our Image class barely readable