File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -752,6 +752,7 @@ def evaluate(
752752 samples = (
753753 hash_dict_images (samples )
754754 if os .environ .get ("LMEVAL_HASHMM" , "1" ) != "0"
755+ and (hasattr (lm , "MULTIMODAL" ))
755756 else samples
756757 )
757758 results_dict ["samples" ] = dict (samples )
Original file line number Diff line number Diff line change @@ -576,10 +576,11 @@ def hash_dict_images(data_dict):
576576 dict: A new dictionary with the same structure as `data_dict`, but with all
577577 bytes and PIL.Image.Image objects replaced by their hashes.
578578 """
579- from PIL import Image
580579
581580 def _process_value (value ):
582581 # Bytes -> hash
582+ from PIL import Image
583+
583584 if isinstance (value , (bytes , bytearray )):
584585 return convert_bytes_to_hash (value )
585586 # PIL Image -> hash
@@ -600,4 +601,8 @@ def _process_value(value):
600601 if not isinstance (data_dict , dict ):
601602 raise TypeError ("Input must be a dictionary" )
602603
603- return {key : _process_value (val ) for key , val in data_dict .items ()}
604+ return (
605+ {key : _process_value (val ) for key , val in data_dict .items ()}
606+ if importlib .util .find_spec ("PIL" )
607+ else data_dict
608+ )
You can’t perform that action at this time.
0 commit comments