Closed Alucard24 closed 2 months ago
Thank you for the feedback. It appears that the default temp folder does not have write permissions. We will provide a parameter in the future to specify the temp folder. @Alucard24
I don't think that the default temp folder doesn't have the write permissions. I changed the code to save in a different folder and I got the same issue:
Traceback (most recent call last):
File "D:\Utility\LivePortrait\app_animals.py", line 47, in
Solved adding the "temp_config_file.close()" before calling the shutil.copyfile function inside "src\utils\dependencies\XPose\util\config.py" file.
def _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)
temp_config_file.close() # Close the file before copying into it
shutil.copyfile(filename,
osp.join(temp_config_dir, temp_config_name))
temp_module_name = osp.splitext(temp_config_name)[0]
sys.path.insert(0, temp_config_dir)
Config._validate_py_syntax(filename)
mod = import_module(temp_module_name)
sys.path.pop(0)
cfg_dict = {
name: value
for name, value in mod.__dict__.items()
if not name.startswith('__')
}
# delete imported module
del sys.modules[temp_module_name]
# close temp file
temp_config_file.close()
elif filename.lower().endswith(('.yml', '.yaml', '.json')):
from .slio import slload
cfg_dict = slload(filename)
else:
raise IOError('Only py/yml/yaml/json type are supported now!')
Solved adding the "temp_config_file.close()" before calling the shutil.copyfile function inside "src\utils\dependencies\XPose\util\config.py" file.
def _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) temp_config_file.close() # Close the file before copying into it shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name)) temp_module_name = osp.splitext(temp_config_name)[0] sys.path.insert(0, temp_config_dir) Config._validate_py_syntax(filename) mod = import_module(temp_module_name) sys.path.pop(0) cfg_dict = { name: value for name, value in mod.__dict__.items() if not name.startswith('__') } # delete imported module del sys.modules[temp_module_name] # close temp file temp_config_file.close() elif filename.lower().endswith(('.yml', '.yaml', '.json')): from .slio import slload cfg_dict = slload(filename) else: raise IOError('Only py/yml/yaml/json type are supported now!')
Thank you very much for your correction and for providing a solution.
works like a charm.
Many thanks to @Alucard24 and @v3ucn for their assistance in #270 and #273. The error has now been resolved.
I have the following issue trying to execute app_animals.py. I have compiled the MultiScaleDeformableAttention extension and I got the same issue also with Administrator user.
Traceback (most recent call last): File "D:\Utility\LivePortrait\app_animals.py", line 47, in
gradio_pipeline_animal: GradioPipelineAnimal = GradioPipelineAnimal(
File "D:\Utility\LivePortrait\src\gradio_pipeline.py", line 341, in init
super().init(inference_cfg, crop_cfg)
File "D:\Utility\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 "D:\Utility\LivePortrait\src\utils\cropper.py", line 77, in init
self.animal_landmark_runner = AnimalLandmarkRunner(
File "D:\Utility\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 "D:\Utility\LivePortrait\src\utils\animal_landmark_runner.py", line 43, in load_animal_model
args = Config.fromfile(model_config_path)
File "D:\Utility\LivePortrait\src\utils\dependencies\XPose\util\config.py", line 186, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename)
File "D:\Utility\LivePortrait\src\utils\dependencies\XPose\util\config.py", line 84, in _file2dict
shutil.copyfile(filename,
File "C:\Users\diegom.conda\envs\LivePortrait\lib\shutil.py", line 266, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\Users\diegom\AppData\Local\Temp\tmpk0h7ffm8\tmpkvchu67b.py'