Refactor image loading in tests to use load_test_image helper#47218
Refactor image loading in tests to use load_test_image helper#47218LevelVoid wants to merge 11 commits into
Conversation
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
|
Hi @tarekziade, |
|
@LevelVoid the linters where updated, can you run we can also remove the COCO urls from |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@tarekziade Thanks! I've updated my local development dependencies, removed the obsolete COCO URLs from fetch_hub_objects_for_ci.py, and pushed the changes. Please let me know if there's anything else you'd like me to update. |
| if is_vision_available(): | ||
| from PIL import Image | ||
| pass |
There was a problem hiding this comment.
something like this to be removed - across the files changed in this PR 🙏
There was a problem hiding this comment.
sure, will remove those across all changed files along.
|
run-slow: aimv2, aria, deepseek_vl_hybrid, eomt, eomt_dinov3, fast_vlm, flava, fuyu, idefics, imagegpt, kimi_k25, layoutlmv2, lfm2_vl, llava, minimax_m3_vl, pix2struct |
|
Workflow Run ⚙️💔 This comment contains |
CI recapDashboard: View test results in Grafana |
| "http://images.cocodataset.org/val2017/000000039769.jpg", | ||
| "http://images.cocodataset.org/val2017/000000077595.jpg", | ||
| "http://images.cocodataset.org/val2017/000000136466.jpg", | ||
| # Legacy COCO URLs have been removed; tests now use the HuggingFace internal testing fixtures mirror. |
There was a problem hiding this comment.
let's remove this comment
|
|
||
| image = Image.open(requests.get("http://images.cocodataset.org/val2017/000000039769.jpg", stream=True).raw) | ||
| image = load_test_image( | ||
| "https://huggingface.co/datasets/hf-internal-testing/fixtures-coco/resolve/main/val2017/000000039769.jpg" |
There was a problem hiding this comment.
Maybe we could use a constant for that dataset as a root url and a simple function load_coco_image
in the commont module:
COCO_DATASET_URL = "https://huggingface.co/datasets/hf-internal-testing/fixtures-coco/resolve/main/val2017"
def load_coco_image(image):
...
then here, just:
load_coco_image("000000039769.jpg")
There was a problem hiding this comment.
Yeah, this will simplify the codebase across multiple files. i will make the changes and push the code.
tarekziade
left a comment
There was a problem hiding this comment.
LGTM I have one small simplification idea
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aimv2, aria, deepseek_vl_hybrid, eomt, eomt_dinov3, fast_vlm, flava, fuyu, idefics, imagegpt, kimi_k25, layoutlmv2, lfm2_vl, llava, minimax_m3_vl, pix2struct |
What does this PR do?
This PR introduces a shared
load_test_imagehelper intests/test_processing_common.pyand updates the affected test files to use it instead of directly downloading COCO fixture images viahttpx.get(...)orrequests.get(...)for the files mentioned in issue #47205.By routing image loading through
url_to_local_path(...), the tests consistently use the local fixture cache when available and remain aligned with the CI prefetch workflow.Fixes #47205
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. These often are low-quality, or fix extremely minor issues that occur rarely or never in practice.
As a result, we're instituting a rule that first-time contributors should not use code agents to submit PRs or issues.
We'd also ask autonomous "OpenClaw"-like agents not to open any PRs or issues.
Issues/PRs from first-time contributors that violate this rule will probably just be closed without review, and we
might block you, especially if you open more than one or appear to be deliberately ignoring this. We especially do not
want new contributors to jump in on random issues to contribute an agent-written fix. This creates lots of noise
for reviewers and other users and will almost certainly get you blocked.
For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request checks?
to it if that's the case. (Link to the issue: Standardize test image fixture loading for COCO images #47205)
Who can review?
@tarekziade As discussed on the issue, this PR implements the requested changes. I'd appreciate your review when you have a chance. Thank you!