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

Windows PermissionError: [Errno 13] Permission denied: 'C:\\Users\\nitin\\AppData\\Local\\Temp\\tmp7x2sbtq5\\tmpyenmu1wn.py' #27

Open
nitinmukesh opened this issue Aug 3, 2024 · 1 comment

Comments

@nitinmukesh
Copy link

nitinmukesh commented Aug 3, 2024

https://github.com/IDEA-Research/X-Pose/blob/master/util/config.py

model_config_path  C:\tut\LivePortrait\src\config\../utils/dependencies/XPose/config_model/UniPose_SwinT.py
model_checkpoint_path  C:\tut\LivePortrait\src\config\../../pretrained_weights/liveportrait_animals/xpose.pth
embeddings_cache_path  C:\tut\LivePortrait\src\config\../utils/resources/clip_embedding
_file2dict  C:/tut/LivePortrait/src/utils/dependencies/XPose/config_model/UniPose_SwinT.py
Help  C:\tut\LivePortrait\src\utils\dependencies\XPose\config_model\UniPose_SwinT.py True
temp_config_name  tmpyenmu1wn.py
temp_config_dir  C:\Users\nitin\AppData\Local\Temp\tmp7x2sbtq5
filename  C:\tut\LivePortrait\src\utils\dependencies\XPose\config_model\UniPose_SwinT.py
fullpath  C:\Users\nitin\AppData\Local\Temp\tmp7x2sbtq5\tmpyenmu1wn.py
Traceback (most recent call last):
  File "C:\tut\LivePortrait\app_animals.py", line 47, in <module>
    gradio_pipeline_animal: GradioPipelineAnimal = GradioPipelineAnimal(
  File "C:\tut\LivePortrait\src\gradio_pipeline.py", line 341, in __init__
    super().__init__(inference_cfg, crop_cfg)
  File "C:\tut\LivePortrait\src\live_portrait_pipeline_animal.py", line 42, in __init__
    self.cropper: Cropper = Cropper(crop_cfg=crop_cfg, image_type='animal_face', flag_use_half_precision=inference_cfg.flag_use_half_precision)
  File "C:\tut\LivePortrait\src\utils\cropper.py", line 81, in __init__
    self.animal_landmark_runner = AnimalLandmarkRunner(
  File "C:\tut\LivePortrait\src\utils\animal_landmark_runner.py", line 30, in __init__
    self.model = self.load_animal_model(model_config_path, model_checkpoint_path, self.device)
  File "C:\tut\LivePortrait\src\utils\animal_landmark_runner.py", line 43, in load_animal_model
    args = Config.fromfile(model_config_path)
  File "C:\tut\LivePortrait\src\utils\dependencies\XPose\util\config.py", line 194, in fromfile
    cfg_dict, cfg_text = Config._file2dict(filename)
  File "C:\tut\LivePortrait\src\utils\dependencies\XPose\util\config.py", line 91, in _file2dict
    shutil.copyfile(filename,
  File "C:\Users\nitin\miniconda3\envs\liveportrait\lib\shutil.py", line 266, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\nitin\\AppData\\Local\\Temp\\tmp7x2sbtq5\\tmpyenmu1wn.py'

If I hardcode the path it works. (temp_config_dir )

@staticmethod
    def _file2dict(filename):
        print("_file2dict ", filename)
        filename = osp.abspath(osp.expanduser(filename))
        check_file_exist(filename)
        if filename.lower().endswith('.py'):
            with tempfile.TemporaryDirectory() as temp_config_dir:
                temp_config_file = tempfile.NamedTemporaryFile(
                    dir=temp_config_dir, suffix='.py')
                temp_config_name = osp.basename(temp_config_file.name)
                print("temp_config_name ", temp_config_name)
                print("temp_config_dir ", temp_config_dir)
                print("filename ", filename)
                print("fullpath ", osp.join(temp_config_dir, temp_config_name))
                temp_config_dir = "c:\\temp"
                shutil.copyfile(filename,
                                osp.join(temp_config_dir, temp_config_name))
                print("=========File copied==========")

shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name)) is causing the error. The temp diectory is writeable

@nitinmukesh
Copy link
Author

Another solution posted

Solved adding the "temp_config_file.close()" before calling the shutil.copyfile function inside "src\utils\dependencies\XPose\util\config.py" file.

Solved adding the "temp_config_file.close()" before calling the shutil.copyfile function inside "src\utils\dependencies\XPose\util\config.py" file.

KwaiVGI/LivePortrait#270 (comment)

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

1 participant