Conversation
|
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. |
| url_to_local_path( | ||
| "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" | ||
| ) |
There was a problem hiding this comment.
First, the name url_to_local_path is misleading, sorry.
It actually check if the file exists locally ( the root of transformers), return local path (i.e. its filename) if it is there, otherwise return the original url.
I will change the name to make it more clear.
But how we need to handle both cases in a better way, but not if (url ) ... else ... (local path) everywhere.
@zucchini-nlp Do we have some excising methods that could handle this well?
(chat template could handle both cases, but here we need some more primitive functions)
There was a problem hiding this comment.
yeah, i remember looking at how url_to_local_path works. Makes sense to me
@zucchini-nlp Do we have some excising methods that could handle this well?
Not sure I got this. Do you mean a method to do url_to_local_path in chat templates?
There was a problem hiding this comment.
No, What I mean is:
this block
requests.get(
url_to_local_path(
"https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
)
but url_to_local_path may return the original url or the local path (if it finds).
Therefore we want to have a simple function to handle both case like here: as requests.get doesn't work with local path.
So I am wondering if you remember if we have already utility functions for doing things like this (and likely used by chat template ..?)
There was a problem hiding this comment.
ahh, no, I don't remember any existing utility we have. Maybe we could put all images/videos/audios in hub and use hf-hub download. AFAIK it should cache everything automatically?
There was a problem hiding this comment.
OK, I find
load_image
src/transformers/image_utils.py
There was a problem hiding this comment.
will use it and merge the PR
There was a problem hiding this comment.
it is the same utility I use in chat templates, and it has no caching mechanism. It will keep sending requests to download every time
There was a problem hiding this comment.
I don't mean simply use it will fix the issue. But it combined with url_to_local_path will (if we have a previous step of downloading the files before the test run step).
i.e.
load_image(url_to_local_path( ... url ...))
will work well (assuming already downloaded)
while
cls.image1 = Image.open(
BytesIO(
requests.get(
url_to_local_path(
"https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
)
)
)
will fail as it can't handle the local path.
(We are talking 2 things different here. My question is more about how to handle (i.e. load things into memory) both cases in a simple way, assuming the files are already downloaded)
There was a problem hiding this comment.
ahh sorry, I misunderstood the comment probably. Right, load_image handles all input types
| url_to_local_path( | ||
| "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" | ||
| ) |
There was a problem hiding this comment.
yeah, i remember looking at how url_to_local_path works. Makes sense to me
@zucchini-nlp Do we have some excising methods that could handle this well?
Not sure I got this. Do you mean a method to do url_to_local_path in chat templates?
4885859 to
e8fdb70
Compare
|
TODO: explore of using |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aria, aya_vision, bridgetower, cohere2_vision, deepseek_vl, deepseek_vl_hybrid, eomt, fuyu, gemma3, gemma3n, glm4v, idefics2, idefics3, internvl, janus, kosmos2 |
|
However:
For 2., we could always upload to a HF hub repo. For 1., the changes need to be done is a bit annoying. For now, I will simply rename This is intended to be used only on a CI environment (CI runners) and not for local development. For now, let's not spend to much time on engineering it |
What does this PR do?
Even more test data cached