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

'NoneType' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead. #142

Closed
cipherpodliq1 opened this issue Feb 17, 2024 · 13 comments · Fixed by #160
Labels
bug Something isn't working

Comments

@cipherpodliq1
Copy link

Traceback (most recent call last):
File "torch\serialization.py", line 354, in _check_seekable
f.seek(f.tell())
AttributeError: 'NoneType' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "dot_main_.py", line 69, in run
File "dot\dot.py", line 131, in generate
File "dot\commons\model_option.py", line 184, in generate_from_camera
File "dot\fomm\option.py", line 93, in create_model
File "dot\fomm\predictor_local.py", line 70, in init
File "dot\fomm\predictor_local.py", line 94, in load_checkpoints
File "torch\serialization.py", line 791, in load
with _open_file_like(f, 'rb') as opened_file:
File "torch\serialization.py", line 276, in _open_file_like
return _open_buffer_reader(name_or_buffer)
File "torch\serialization.py", line 261, in init
_check_seekable(buffer)
File "torch\serialization.py", line 357, in _check_seekable
raise_err_msg(["seek", "tell"], e)
File "torch\serialization.py", line 350, in raise_err_msg
raise type(e)(msg)
AttributeError: 'NoneType' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.

Does it have something to do with the image format that I am trying to load? (jpg) , or maybe missing some of the requirments? (I downloaded the requirments .txt)

@cipherpodliq1 cipherpodliq1 added the bug Something isn't working label Feb 17, 2024
@isrvo
Copy link

isrvo commented Feb 23, 2024

+1

I'm having the same issue while trying to run with simswap or fomm, the only swap option that doesn't break it's faceswap_cv2.

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 70, in __init__
  File "dot\fomm\predictor_local.py", line 94, in load_checkpoints
  File "torch\serialization.py", line 791, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "torch\serialization.py", line 276, in _open_file_like
    return _open_buffer_reader(name_or_buffer)
  File "torch\serialization.py", line 261, in __init__
    _check_seekable(buffer)
  File "torch\serialization.py", line 357, in _check_seekable
    raise_err_msg(["seek", "tell"], e)
  File "torch\serialization.py", line 350, in raise_err_msg
    raise type(e)(msg)
AttributeError: 'NoneType' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.

@Ghassen-Chaabouni
Copy link
Contributor

@cipherpodliq1 @isrvo Can you confirm that you have the fomm model saved under saved_models/fomm/vox-adv-cpk.pth.tar ?

@isrvo
Copy link

isrvo commented Mar 1, 2024

@Ghassen-Chaabouni Yes I do, it is still compressed but is present under saved_models/fomm/vox-adv-cpk.pth.tar

@cipherpodliq1
Copy link
Author

Same here , vox-adv-cpk.pth is the file that I have

@Ghassen-Chaabouni
Copy link
Contributor

@isrvo @cipherpodliq1 I think I will need more information to debug this issue.
Can you answer these questions?

  • What python and pytorch versions are you using?
  • Are you using GPU? If so, what is the output of python -c "import torch; print(torch.cuda.is_available())" and what CUDA version you have installed?
  • Are you using the GUI or the CLI? And what are the options or the command that you are using?
  • What OS are you running dot on?
  • Are you using the latest checkpoints and the latest version of the repo and the GUI?

@OnlyStopOnTop
Copy link

me, too

What python and pytorch versions are you using?

2.0.1+cu118
Are you using GPU? If so, what is the output of python -c "import torch; print(torch.cuda.is_available())" and what CUDA version you have installed?
cuda 11.8, output is True
Are you using the GUI or the CLI? And what are the options or the command that you are using?
GUI
What OS are you running dot on?
W11
Are you using the latest checkpoints and the latest version of the repo and the GUI?
yes

@isrvo
Copy link

isrvo commented Mar 13, 2024

On my side um running dot with GUI on Windows.
I've downloaded the dot.zip package and after trying to run with fomm the output is:

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 71, in __init__
  File "face_alignment\api.py", line 75, in __init__
    self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose)
  File "I:\Downloads\dot\face_alignment\detection\sfd\sfd_detector.py", line 24, in __init__
    model_weights = load_url(models_urls['s3fd'])
  File "torch\hub.py", line 741, in load_state_dict_from_url
    sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
OSError: [WinError 6] The handle is invalid

I've redownloaded all files as of today.

@kbeeperez
Copy link

kbeeperez commented Apr 17, 2024

On my side um running dot with GUI on Windows. I've downloaded the dot.zip package and after trying to run with fomm the output is:

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 71, in __init__
  File "face_alignment\api.py", line 75, in __init__
    self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose)
  File "I:\Downloads\dot\face_alignment\detection\sfd\sfd_detector.py", line 24, in __init__
    model_weights = load_url(models_urls['s3fd'])
  File "torch\hub.py", line 741, in load_state_dict_from_url
    sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
OSError: [WinError 6] The handle is invalid

I've redownloaded all files as of today.

@isrvo Where you able to fix this issue? I am currently running into it with the FOMM model.

@Ghassen-Chaabouni
Copy link
Contributor

On my side um running dot with GUI on Windows. I've downloaded the dot.zip package and after trying to run with fomm the output is:

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 71, in __init__
  File "face_alignment\api.py", line 75, in __init__
    self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose)
  File "I:\Downloads\dot\face_alignment\detection\sfd\sfd_detector.py", line 24, in __init__
    model_weights = load_url(models_urls['s3fd'])
  File "torch\hub.py", line 741, in load_state_dict_from_url
    sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
OSError: [WinError 6] The handle is invalid

I've redownloaded all files as of today.

@isrvo Where you able to fix this issue? I am currently running into it with the FOMM model.

@kbeeperez @isrvo I think you are running custom scripts. A similar issue was addressed in this PR #137 . It seems that you are getting an error when trying to download a model. You can instead manually download the models and pass the local url. Like I did here

@Ghassen-Chaabouni
Copy link
Contributor

+1

I'm having the same issue while trying to run with simswap or fomm, the only swap option that doesn't break it's faceswap_cv2.

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 70, in __init__
  File "dot\fomm\predictor_local.py", line 94, in load_checkpoints
  File "torch\serialization.py", line 791, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "torch\serialization.py", line 276, in _open_file_like
    return _open_buffer_reader(name_or_buffer)
  File "torch\serialization.py", line 261, in __init__
    _check_seekable(buffer)
  File "torch\serialization.py", line 357, in _check_seekable
    raise_err_msg(["seek", "tell"], e)
  File "torch\serialization.py", line 350, in raise_err_msg
    raise type(e)(msg)
AttributeError: 'NoneType' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.

@isrvo Did you manage to get pass this error? Did you just redownloaded the models again or you did something else?

@isrvo
Copy link

isrvo commented Apr 29, 2024

@Ghassen-Chaabouni I've still not managed to dry-run it with fomm models.

I'll retry-it later today with the following instructions mentioned above.

@isrvo
Copy link

isrvo commented May 28, 2024

@Ghassen-Chaabouni sorry for the late answer.
I've redid all the steps with a fresh new computer and still didn't managed to use fomm swap method.
I've redownloaded the files through the Google Drive link, opened the dot.exe file, selected the config file for fomm and clicked run.

I've still received the same Download error:

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 71, in __init__
  File "face_alignment\api.py", line 75, in __init__
    self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose)
  File "I:\Downloads\dot\face_alignment\detection\sfd\sfd_detector.py", line 24, in __init__
    model_weights = load_url(models_urls['s3fd'])
  File "torch\hub.py", line 741, in load_state_dict_from_url
    sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
OSError: [WinError 6] The handle is invalid

I would like to mention that I have all the necessary dependencies to work with CUDA and Nvidia as well.
Can you provide further instructions on how to manually swap the fomm models on the code as you mentioned before?

@Ghassen-Chaabouni
Copy link
Contributor

@Ghassen-Chaabouni sorry for the late answer. I've redid all the steps with a fresh new computer and still didn't managed to use fomm swap method. I've redownloaded the files through the Google Drive link, opened the dot.exe file, selected the config file for fomm and clicked run.

I've still received the same Download error:

Traceback (most recent call last):
  File "dot\__main__.py", line 69, in run
  File "dot\dot.py", line 131, in generate
  File "dot\commons\model_option.py", line 184, in generate_from_camera
  File "dot\fomm\option.py", line 93, in create_model
  File "dot\fomm\predictor_local.py", line 71, in __init__
  File "face_alignment\api.py", line 75, in __init__
    self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose)
  File "I:\Downloads\dot\face_alignment\detection\sfd\sfd_detector.py", line 24, in __init__
    model_weights = load_url(models_urls['s3fd'])
  File "torch\hub.py", line 741, in load_state_dict_from_url
    sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
OSError: [WinError 6] The handle is invalid

I would like to mention that I have all the necessary dependencies to work with CUDA and Nvidia as well. Can you provide further instructions on how to manually swap the fomm models on the code as you mentioned before?

It seems that you aren't able to download some models. Can you try this version of dot from this link? I downloaded the models in it and updated a script to use them. Let me know if this fixed your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants