"[Errno 13] Permission denied" build safetensors via api /faceswaplab/build #84
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello, thankyou for greate job, but i have some trouble with api, when i build safetensors via /faceswaplab/build server, send me error
"[Errno 13] Permission denied" model has created but not save, only save preview PNG file with swaped face in D:\SD_port\tmp\ folder
I use portable version of automatic1111 can you help me?
there are error code from automatic console
`2023-08-31 06:33:15,525 - FaceSwapLab - STATUS - Build api_ckpt with 7 images
2023-08-31 06:33:18,487 - FaceSwapLab - STATUS - Source Gender 0
2023-08-31 06:33:18,496 - FaceSwapLab - STATUS - Target faces count : 1
2023-08-31 06:33:18,497 - FaceSwapLab - STATUS - swap face 0
2023-08-31 06:33:19,019 - FaceSwapLab - STATUS - ********************************************************************************
2023-08-31 06:33:19,029 - FaceSwapLab - STATUS - Inswapper
2023-08-31 06:33:19,033 - FaceSwapLab - STATUS - Upscale with Lanczos scale = 4
2023-08-31 06:33:19,039 - FaceSwapLab - STATUS - Restore face with CodeFormer
2023-08-31 06:33:19,508 - FaceSwapLab - STATUS - sharpen
2023-08-31 06:33:19,511 - FaceSwapLab - STATUS - improved_mask
2023-08-31 06:33:19,577 - FaceSwapLab - STATUS - ********************************************************************************
2023-08-31 06:33:19,716 - FaceSwapLab - ERROR - Error loading checkpoint, after creation could not open file <D:\SD_port\tmp\tmp4gpb3bvj.safetensors> in read-only mode; error code: <32>
Traceback (most recent call last):
File "D:\SD_port\extensions\sd-webui-faceswaplab\scripts\faceswaplab_swapping\face_checkpoints.py", line 129, in build_face_checkpoint_and_save
data = load_face(file_path)
File "D:\SD_port\extensions\sd-webui-faceswaplab\scripts\faceswaplab_swapping\face_checkpoints.py", line 194, in load_face
with safe_open(filename, framework="pt", device="cpu") as f:
RuntimeError: could not open file <D:\SD_port\tmp\tmp4gpb3bvj.safetensors> in read-only mode; error code: <32>
D:\SD_port\tmp\tmp4gpb3bvj.safetensors
*** API error: POST: http://127.0.0.1:7860/faceswaplab/build {'error': 'PermissionError', 'detail': '', 'body': '', 'errors': "[Errno 13] Permission denied: 'D:\\SD_port\\tmp\\tmp4gpb3bvj.safetensors'"}
Traceback (most recent call last):
File "D:\SD_port\venv\lib\site-packages\anyio\streams\memory.py", line 94, in receive
return self.receive_nowait()
File "D:\SD_port\venv\lib\site-packages\anyio\streams\memory.py", line 89, in receive_nowait
raise WouldBlock
anyio.WouldBlock
i test your code and safetensors file is created, but only if i change path or name of file. My test stop at safetensors_to_base64 in api_utils.py i am sorry i am newbie, "safetensors_to_base64" cannot open file
file was deleted by 'tempfile' i set to delete=False and it work, code in faceswaplab_api.py
@app.post( "/faceswaplab/build", tags=["faceswaplab"], description="Build a face checkpoint using base64 images, return base64 satetensors", ) async def build(base64_images: List[str]) -> Optional[str]: if len(base64_images) > 0: pil_images = [base64_to_pil(img) for img in base64_images] with tempfile.NamedTemporaryFile( **delete=True,** suffix=".safetensors" ) as temp_file: build_face_checkpoint_and_save( images=pil_images, name="api_ckpt", overwrite=True, path=temp_file.name, ) return api_utils.safetensors_to_base64(temp_file.name) return None