Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
ab3acc73
Unverified
Commit
ab3acc73
authored
Jul 06, 2025
by
Baber Abbasi
Committed by
GitHub
Jul 06, 2025
Browse files
check pil dep (#3114)
parent
89654090
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
lm_eval/evaluator.py
lm_eval/evaluator.py
+1
-0
lm_eval/utils.py
lm_eval/utils.py
+7
-2
No files found.
lm_eval/evaluator.py
View file @
ab3acc73
...
...
@@ -752,6 +752,7 @@ def evaluate(
samples
=
(
hash_dict_images
(
samples
)
if
os
.
environ
.
get
(
"LMEVAL_HASHMM"
,
"1"
)
!=
"0"
and
(
hasattr
(
lm
,
"MULTIMODAL"
))
else
samples
)
results_dict
[
"samples"
]
=
dict
(
samples
)
...
...
lm_eval/utils.py
View file @
ab3acc73
...
...
@@ -576,10 +576,11 @@ def hash_dict_images(data_dict):
dict: A new dictionary with the same structure as `data_dict`, but with all
bytes and PIL.Image.Image objects replaced by their hashes.
"""
from
PIL
import
Image
def
_process_value
(
value
):
# Bytes -> hash
from
PIL
import
Image
if
isinstance
(
value
,
(
bytes
,
bytearray
)):
return
convert_bytes_to_hash
(
value
)
# PIL Image -> hash
...
...
@@ -600,4 +601,8 @@ def hash_dict_images(data_dict):
if
not
isinstance
(
data_dict
,
dict
):
raise
TypeError
(
"Input must be a dictionary"
)
return
{
key
:
_process_value
(
val
)
for
key
,
val
in
data_dict
.
items
()}
return
(
{
key
:
_process_value
(
val
)
for
key
,
val
in
data_dict
.
items
()}
if
importlib
.
util
.
find_spec
(
"PIL"
)
else
data_dict
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment