sensity-ai / dot

The Deepfake Offensive Toolkit
BSD 3-Clause "New" or "Revised" License
4.14k stars 411 forks source link

'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 closed 5 months ago

cipherpodliq1 commented 9 months ago

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)

isrvo commented 8 months ago

+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 commented 8 months ago

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

isrvo commented 8 months ago

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

cipherpodliq1 commented 8 months ago

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

Ghassen-Chaabouni commented 8 months ago

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

OnlyStopOnTop commented 8 months ago

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 commented 8 months ago

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 commented 7 months ago

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 commented 6 months ago

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 commented 6 months ago

+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 commented 6 months ago

@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 commented 5 months ago

@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 commented 5 months ago

@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.