Repository navigation
fix(vision): the TrOCR and Florence-2 tiers get a Buffer image as a Blob - #229
Conversation
VisionPipeline handed transformers.js a Buffer as a data URL string. In Node, transformers.js reads a string that is not an http(s) or blob: URL as a file path (getFile in its utils/hub.js), so the handwriting and document-layout tiers failed on every Buffer input. The vision-pipeline pack now fetches http(s) images itself and passes the bytes, which made those tiers fail for every image it handles. A Buffer now goes in a Blob, which transformers.js decodes with sharp (RawImage.fromBlob); a URL string goes as it is.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideFixes local TrOCR and Florence-2 failures for Buffer-backed images by passing Buffers as Blob objects, which transformers.js can decode in Node, while retaining URL strings unchanged; tests pin this boundary contract with mocked pipelines. Sequence diagram for Blob-based vision pipeline inputssequenceDiagram
participant VisionPipeline
participant transformersImage
participant TransformersJS
VisionPipeline->>transformersImage: transformersImage(image)
alt image is Buffer
transformersImage->>transformersImage: bufferToBlobPart(image)
transformersImage-->>VisionPipeline: Blob
else image is URL string
transformersImage-->>VisionPipeline: URL string
end
VisionPipeline->>TransformersJS: pipe(input)
TransformersJS-->>VisionPipeline: generated output
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 38 minutes for your next included review. View limit detailsLimit details: You’ve used all 4 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Comment |
PR Summary by QodoPass Buffer images as Blobs to TrOCR and Florence-2
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent |
## [0.13.23](v0.13.22...v0.13.23) (2026-10-10) ### fix * **gmi:** follow-ups from the reviews of #193 and #199 (#217) ([2bacb69](2bacb69)) * **gmi:** manager shutdown waits for creations in flight, bounds each GMI and runs once (#222) ([d99b126](d99b126)) * **images:** the untrusted fetch settles on a protocol upgrade, and four review follow-ups (#227) ([9efb4b5](9efb4b5)) * **vision:** the TrOCR and Florence-2 tiers get a Buffer image as a Blob (#229) ([7fe444a](7fe444a))
What this fixes
The handwriting (TrOCR) and document-layout (Florence-2) tiers failed on every image given as a
Buffer.VisionPipelineturned a Buffer into adata:image/png;base64,...string before handing it to the transformers.jsimage-to-textpipeline. In Node, transformers.js reads a string that is not anhttp:,https:orblob:URL as a file path.getFilein utils/hub.js takes theenv.useFSbranch,RawImage.fromURLgets a 404 and throws, and the tier fails.This was reachable before, but it now hits every http(s) image the vision-pipeline pack handles. Since framerslab/agentos-extensions#105 the pack fetches the image itself through
imageToBuffer(url, { untrusted: true })and passes the bytes. The tool still returnedsuccess: true, with OCR-only text or a cloud tier's result in place of TrOCR's or Florence-2's.A Buffer now goes in a
Blob. The pipelines takestring | RawImage | URL | Blob(pipelines.js,ImageInput), andRawImage.fromBlobdecodes a Blob with sharp in Node (utils/image.js). A URL string goes as it is.Found by a cold security read of #211 and agentos-extensions #105.
Tests
In
VisionPipeline.test.ts, with the transformers.js pipeline factory mocked to record its input:Blob;Blob, and one given as a URL reaches it as the same string.A run against the real models would download them in CI, so the contract is pinned at the call into transformers.js.
Not in this change
The CLIP tier runs the text
feature-extractiontask, so it never sees an image. That limit is documented in VISION_PIPELINE.md and needs its own change: theimage-feature-extractiontask.Summary by Sourcery
Ensure local image-to-text vision tiers receive image inputs in a format transformers.js can decode reliably.
Bug Fixes:
Enhancements:
Tests: