-
Notifications
You must be signed in to change notification settings - Fork 220
Add Load Image From URL workflow block #1498
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
base: main
Are you sure you want to change the base?
Conversation
5bc8798 to
fb5726e
Compare
- Add LoadImageFromUrlBlockV1 transformation block - Support Union types for URL and cache inputs (direct values + parameters) - Implement LRU cache for image storage - Use existing load_image_from_url for security/validation - Add comprehensive test suite (17 tests, 100% requirement coverage) - Update block icon from fa-download to fa-image - Register block in workflow loader 🤖 Generated with [Claude Code](https://claude.ai/code)
- Fix black formatting issues in load_image_from_url/v1.py - Fix import sorting in loader.py 🤖 Generated with [Claude Code](https://claude.ai/code)
fb5726e to
3fd90b7
Compare
- Add LoadImageFromUrlBlockV1 transformation block - Support Union types for URL and cache inputs (direct values + parameters) - Implement LRU cache for image storage - Use existing load_image_from_url for security/validation - Add comprehensive test suite (17 tests, 100% requirement coverage) - Update block icon from fa-download to fa-image - Register block in workflow loader 🤖 Generated with [Claude Code](https://claude.ai/code)
- Fix black formatting issues in load_image_from_url/v1.py - Fix import sorting in loader.py 🤖 Generated with [Claude Code](https://claude.ai/code)
3fd90b7 to
3d2989b
Compare
…github.com/roboflow/inference into feature-load-image-from-url-workflow-block
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.
Working for loading image & passing to some blocks but Model blocks seem to require a Batch oriented image & can't figure out how to modify this in a way that tells the execution engine that it's properly batched.
…-image-from-url-workflow-block`) The optimization applies **module-level pre-computation** to eliminate repeated list construction. The original code creates a new 122-element list every time `load_blocks()` is called, while the optimized version creates the list once at import time and stores it in a module constant `_BLOCKS`. **Key changes:** - **Pre-computed constant**: The block list is moved to module-level constant `_BLOCKS`, constructed once during import - **Direct return**: `load_blocks()` now simply returns the pre-built list instead of constructing it each call **Why this achieves 713% speedup:** - **Eliminates list construction overhead**: The original spends ~80% of execution time (14.9ms out of 18.7ms) just constructing the list literal with 122 class references - **Reduces memory allocations**: No repeated list object creation on each function call - **Maintains object reference semantics**: Same classes are returned, preserving all behavior and type information **Test case performance patterns:** The optimization shows consistent 600-900% speedup across all test scenarios, with particularly strong gains in: - Repeated calls (784-936% faster) - benefits most from avoiding re-construction - Large-scale operations that call `load_blocks()` multiple times - Basic functionality tests (615-762% faster) - all benefit from the single list return This is a classic **constant folding** optimization where expensive computation (list construction) is moved from runtime to import time.
⚡️ Codeflash found optimizations for this PR📄 714% (7.14x) speedup for
|
|
@Grantimus9 still workgin on this? I think the required changes in execution engine laded. Any other blockers or maybe we just need to merge in latest master and test? |
|
Just merge and test. Don't wait on me, but I'm also happy to do it later, probably tomorrow. |
Summary
Implements a new workflow block that loads images from URLs with caching capabilities. This block enables workflows to dynamically fetch images from web URLs and use them as input for other workflow steps.
Features
$inputs.image_url)load_image_from_urlfunction for URL validation and secure image loadingImplementation Details
roboflow_core/load_image_from_url@v1url: Image URL (string or parameter reference)cache: Enable/disable caching (boolean or parameter reference, defaults totrue)image- WorkflowImageData object ready for use in other workflow stepsfas fa-imagefor visual identificationTesting
Files Added/Modified
inference/core/workflows/core_steps/transformations/load_image_from_url/v1.py- Main implementationinference/core/workflows/core_steps/transformations/load_image_from_url/__init__.py- Module initializationtests/workflows/unit_tests/core_steps/transformations/test_load_image_from_url.py- Test suiteinference/core/workflows/core_steps/loader.py- Block registration🤖 Generated with Claude Code