inference icon indicating copy to clipboard operation
inference copied to clipboard

Add Load Image From URL workflow block

Open Grantimus9 opened this issue 4 months ago • 4 comments

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

  • URL Input Support: Accepts both direct URL strings and parameter references ($inputs.image_url)
  • Caching: Optional LRU cache to avoid re-downloading the same images (enabled by default)
  • Security: Uses existing load_image_from_url function for URL validation and secure image loading
  • Error Handling: Comprehensive error handling with descriptive messages for invalid URLs or unsupported formats
  • Union Types: Supports both direct values and parameter references for all inputs

Implementation Details

  • Block Type: roboflow_core/load_image_from_url@v1
  • Inputs:
    • url: Image URL (string or parameter reference)
    • cache: Enable/disable caching (boolean or parameter reference, defaults to true)
  • Output: image - WorkflowImageData object ready for use in other workflow steps
  • Icon: Uses fas fa-image for visual identification

Testing

  • 17 comprehensive tests covering all functionality
  • Tests use mocking to avoid network dependencies during CI/CD
  • Validates manifest creation, runtime behavior, caching, and error handling
  • Includes specific test for real-world URL scenarios

Files Added/Modified

  • inference/core/workflows/core_steps/transformations/load_image_from_url/v1.py - Main implementation
  • inference/core/workflows/core_steps/transformations/load_image_from_url/__init__.py - Module initialization
  • tests/workflows/unit_tests/core_steps/transformations/test_load_image_from_url.py - Test suite
  • inference/core/workflows/core_steps/loader.py - Block registration

🤖 Generated with Claude Code

Grantimus9 avatar Aug 19 '25 23:08 Grantimus9

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 19 '25 23:08 CLAassistant

⚡️ Codeflash found optimizations for this PR

📄 714% (7.14x) speedup for load_blocks in inference/core/workflows/core_steps/loader.py

⏱️ Runtime : 158 microseconds 19.4 microseconds (best of 266 runs)

I created a new dependent PR with the suggested changes. Please review:

  • #1514

If you approve, it will be merged into this PR (branch feature-load-image-from-url-workflow-block).

codeflash-ai[bot] avatar Aug 26 '25 16:08 codeflash-ai[bot]

@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?

hansent avatar Sep 04 '25 18:09 hansent

Just merge and test. Don't wait on me, but I'm also happy to do it later, probably tomorrow.

Grantimus9 avatar Sep 04 '25 18:09 Grantimus9