mirror of
https://github.com/facefusion/facefusion-comfyui.git
synced 2026-06-06 19:13:53 +02:00
Introduce retry logic, Install before the imports
This commit is contained in:
+2
-1
@@ -1,8 +1,9 @@
|
||||
from .facefusion_api import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||||
from .install import install
|
||||
|
||||
install()
|
||||
|
||||
from .facefusion_api import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||||
|
||||
__all__ =\
|
||||
[
|
||||
'NODE_CLASS_MAPPINGS',
|
||||
|
||||
@@ -9,6 +9,7 @@ from comfy_api.input_impl.video_types import VideoFromComponents
|
||||
from comfy_api.util import VideoComponents
|
||||
from comfy_api_nodes.apinode_utils import bytesio_to_image_tensor, tensor_to_bytesio
|
||||
from httpx import Client as HttpClient, Headers
|
||||
from httpx_retries import Retry, RetryTransport
|
||||
from torch import Tensor
|
||||
|
||||
from .types import FaceSwapperModel, InputTypes
|
||||
@@ -69,11 +70,13 @@ class SwapFaceImage:
|
||||
'face_swapper_model': face_swapper_model,
|
||||
}
|
||||
headers = Headers()
|
||||
retry = Retry(total = 5, backoff_factor = 1)
|
||||
transport = RetryTransport(retry = retry)
|
||||
|
||||
if api_token:
|
||||
headers['X-Token'] = api_token
|
||||
|
||||
with HttpClient(timeout = 10) as http_client:
|
||||
with HttpClient(transport = transport) as http_client:
|
||||
response = http_client.post(url, headers = headers, files = files, data = data)
|
||||
|
||||
output_buffer = BytesIO(response.content)
|
||||
|
||||
+2
-1
@@ -3,4 +3,5 @@ from shutil import which
|
||||
|
||||
|
||||
def install() -> None:
|
||||
subprocess.run([ which('pip'), 'install', '-r', 'requirements.txt', '-q' ])
|
||||
subprocess.run([ which('pip'), 'install', 'httpx==0.28.1', '-q' ])
|
||||
subprocess.run([ which('pip'), 'install', 'httpx-retries==0.4.0', '-q' ])
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
httpx==0.28.1
|
||||
|
||||
httpx-retries==0.4.0
|
||||
|
||||
Reference in New Issue
Block a user