Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in histogram file name on Windows 10. #59

Open
tahoemike opened this issue Jan 9, 2024 · 1 comment
Open

Error in histogram file name on Windows 10. #59

tahoemike opened this issue Jan 9, 2024 · 1 comment

Comments

@tahoemike
Copy link

Got this error on Windows 10 running:

C:\Python310\lib\site-packages\deep_audio_features\bin\basic_training.py -i "genres/blues" "genres/classical" "genres/country" "genres/disco" "genres/hiphop", "genres/jazz" "genres/metal" "genres/pop" "genres/reggae" "genres/rock" -o "energy"

...
--> Plotting histogram of spectrogram sizes.
Traceback (most recent call last):
File "", line 1, in
File "C:\Python310\lib\site-packages\deep_audio_features\bin\basic_training.py", line 64, in train_model
train_set = FeatureExtractorDataset(X=files_train, y=y_train,
File "C:\Python310\lib\site-packages\deep_audio_features\dataloading\dataloading.py", line 86, in init
self.plot_hist(spec_sizes, y)
File "C:\Python310\lib\site-packages\deep_audio_features\dataloading\dataloading.py", line 261, in plot_hist
plt.savefig(ct.strftime("%m_%d_%Y, %H:%M:%S") + ".png")
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\pyplot.py", line 1023, in savefig
res = fig.savefig(*args, **kwargs)
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\figure.py", line 3378, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\backend_bases.py", line 2366, in print_figure
result = print_method(
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\backend_bases.py", line 2232, in
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\backends\backend_agg.py", line 509, in print_png
self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\backends\backend_agg.py", line 458, in _print_pil
mpl.image.imsave(
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\matplotlib\image.py", line 1689, in imsave
image.save(fname, **pil_kwargs)
File "C:\Python310\Lib\site-packages\deep_audio_features\utils../..\PIL\Image.py", line 2410, in save
fp = builtins.open(filename, "w+b")
OSError: [Errno 22] Invalid argument: '01_09_2024, 08:51:43.png'

@iamaer4fa
Copy link

iamaer4fa commented Mar 31, 2024

This is the patch for file Image.py:

import re

def sanitize_filename(filename):
    invalid_chars = r"[<>:\"/\\|?*]"  # Expand with other bad chars if needed
    new_filename = re.sub(invalid_chars, '_', filename)  # Replace with underscores
    return new_filename

Inside your save function

filename = sanitize_filename(filename)
fp = builtins.open(filename, "w+b") 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants