mirror of
https://github.com/facefusion/facefusion.git
synced 2026-10-14 17:40:48 +02:00
ship libssl and libcrypto in linux (#1095)
This commit is contained in:
1 parent
bb1b8ccf13
commit
20b392f760
5 files changed
+218
-94
No files matched your search
@@ -1,47 +1,97 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import os
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Optional
|
||||||
|
|
||||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||||
from facefusion.filesystem import resolve_relative_path
|
from facefusion.filesystem import resolve_relative_path
|
||||||
from facefusion.types import DownloadSet
|
from facefusion.types import LibrarySet
|
||||||
|
|
||||||
|
|
||||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
|
||||||
if is_linux():
|
|
||||||
return 'linux/libdatachannel.hash', 'linux/libdatachannel.so'
|
|
||||||
if is_macos():
|
|
||||||
return 'macos/libdatachannel.hash', 'macos/libdatachannel.dylib'
|
|
||||||
if is_windows():
|
|
||||||
return 'windows/datachannel.hash', 'windows/datachannel.dll'
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
def create_static_library_set() -> Optional[LibrarySet]:
|
||||||
library_hash_path, library_source_path = resolve_library_paths()
|
if is_linux():
|
||||||
|
return\
|
||||||
return\
|
|
||||||
{
|
|
||||||
'hashes':
|
|
||||||
{
|
{
|
||||||
'datachannel':
|
'hashes':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
'datachannel':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
{
|
||||||
}
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libdatachannel.hash'),
|
||||||
},
|
'path': resolve_relative_path('../.libraries/libdatachannel.hash')
|
||||||
'sources':
|
},
|
||||||
{
|
'crypto':
|
||||||
'datachannel':
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libcrypto.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libcrypto.hash')
|
||||||
|
},
|
||||||
|
'ssl':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libssl.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libssl.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
'datachannel':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libdatachannel.so'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libdatachannel.so')
|
||||||
|
},
|
||||||
|
'crypto':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libcrypto.so'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libcrypto.so')
|
||||||
|
},
|
||||||
|
'ssl':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libssl.so'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libssl.so')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if is_macos():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'datachannel':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libdatachannel.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libdatachannel.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'datachannel':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libdatachannel.dylib'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libdatachannel.dylib')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if is_windows():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'datachannel':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/datachannel.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/datachannel.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'datachannel':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/datachannel.dll'),
|
||||||
|
'path': resolve_relative_path('../.libraries/datachannel.dll')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def pre_check() -> bool:
|
def pre_check() -> bool:
|
||||||
@@ -53,13 +103,19 @@ def pre_check() -> bool:
|
|||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def create_static_library() -> Optional[ctypes.CDLL]:
|
def create_static_library() -> Optional[ctypes.CDLL]:
|
||||||
library_path = create_static_library_set().get('sources').get('datachannel').get('path')
|
datachannel_source_path = create_static_library_set().get('sources').get('datachannel').get('path')
|
||||||
|
crypto_source_path = create_static_library_set().get('sources').get('crypto').get('path')
|
||||||
|
ssl_source_path = create_static_library_set().get('sources').get('ssl').get('path')
|
||||||
|
|
||||||
|
if datachannel_source_path:
|
||||||
|
if crypto_source_path and ssl_source_path:
|
||||||
|
ctypes.CDLL(crypto_source_path)
|
||||||
|
ctypes.CDLL(ssl_source_path)
|
||||||
|
|
||||||
if library_path:
|
|
||||||
if is_windows():
|
if is_windows():
|
||||||
library = ctypes.CDLL(library_path, winmode = 0)
|
library = ctypes.CDLL(datachannel_source_path, winmode = 0)
|
||||||
else:
|
else:
|
||||||
library = ctypes.CDLL(library_path)
|
library = ctypes.CDLL(datachannel_source_path)
|
||||||
|
|
||||||
if library:
|
if library:
|
||||||
return init_ctypes(library)
|
return init_ctypes(library)
|
||||||
|
|||||||
@@ -1,47 +1,79 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import os
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Optional
|
||||||
|
|
||||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||||
from facefusion.filesystem import resolve_relative_path
|
from facefusion.filesystem import resolve_relative_path
|
||||||
from facefusion.types import DownloadSet
|
from facefusion.types import LibrarySet
|
||||||
|
|
||||||
|
|
||||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
|
||||||
if is_linux():
|
|
||||||
return 'linux/libopus.hash', 'linux/libopus.so'
|
|
||||||
if is_macos():
|
|
||||||
return 'macos/libopus.hash', 'macos/libopus.dylib'
|
|
||||||
if is_windows():
|
|
||||||
return 'windows/opus.hash', 'windows/opus.dll'
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
def create_static_library_set() -> Optional[LibrarySet]:
|
||||||
library_hash_path, library_source_path = resolve_library_paths()
|
if is_linux():
|
||||||
|
return\
|
||||||
return\
|
|
||||||
{
|
|
||||||
'hashes':
|
|
||||||
{
|
{
|
||||||
'opus':
|
'hashes':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
'opus':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
{
|
||||||
}
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libopus.hash'),
|
||||||
},
|
'path': resolve_relative_path('../.libraries/libopus.hash')
|
||||||
'sources':
|
}
|
||||||
{
|
},
|
||||||
'opus':
|
'sources':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
'opus':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libopus.so'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libopus.so')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if is_macos():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'opus':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libopus.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libopus.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'opus':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libopus.dylib'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libopus.dylib')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_windows():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'opus':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/opus.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/opus.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'opus':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/opus.dll'),
|
||||||
|
'path': resolve_relative_path('../.libraries/opus.dll')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def pre_check() -> bool:
|
def pre_check() -> bool:
|
||||||
|
|||||||
+60
-30
@@ -1,47 +1,77 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import os
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Optional
|
||||||
|
|
||||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||||
from facefusion.filesystem import resolve_relative_path
|
from facefusion.filesystem import resolve_relative_path
|
||||||
from facefusion.types import DownloadSet
|
from facefusion.types import LibrarySet
|
||||||
|
|
||||||
|
|
||||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
|
||||||
if is_linux():
|
|
||||||
return 'linux/libvpx.hash', 'linux/libvpx.so'
|
|
||||||
if is_macos():
|
|
||||||
return 'macos/libvpx.hash', 'macos/libvpx.dylib'
|
|
||||||
if is_windows():
|
|
||||||
return 'windows/vpx.hash', 'windows/vpx.dll'
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
def create_static_library_set() -> Optional[LibrarySet]:
|
||||||
library_hash_path, library_source_path = resolve_library_paths()
|
if is_linux():
|
||||||
|
return\
|
||||||
return\
|
|
||||||
{
|
|
||||||
'hashes':
|
|
||||||
{
|
{
|
||||||
'vpx':
|
'hashes':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
'vpx':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
{
|
||||||
}
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libvpx.hash'),
|
||||||
},
|
'path': resolve_relative_path('../.libraries/libvpx.hash')
|
||||||
'sources':
|
}
|
||||||
{
|
},
|
||||||
'vpx':
|
'sources':
|
||||||
{
|
{
|
||||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
'vpx':
|
||||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libvpx.so'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libvpx.so')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if is_macos():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'vpx':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libvpx.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libvpx.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'vpx':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libvpx.dylib'),
|
||||||
|
'path': resolve_relative_path('../.libraries/libvpx.dylib')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if is_windows():
|
||||||
|
return\
|
||||||
|
{
|
||||||
|
'hashes':
|
||||||
|
{
|
||||||
|
'vpx':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/vpx.hash'),
|
||||||
|
'path': resolve_relative_path('../.libraries/vpx.hash')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'sources':
|
||||||
|
{
|
||||||
|
'vpx':
|
||||||
|
{
|
||||||
|
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/vpx.dll'),
|
||||||
|
'path': resolve_relative_path('../.libraries/vpx.dll')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def pre_check() -> bool:
|
def pre_check() -> bool:
|
||||||
|
|||||||
@@ -282,6 +282,9 @@ ModelOptions : TypeAlias = Dict[str, Any]
|
|||||||
ModelSet : TypeAlias = Dict[str, ModelOptions]
|
ModelSet : TypeAlias = Dict[str, ModelOptions]
|
||||||
ModelInitializer : TypeAlias = NDArray[Any]
|
ModelInitializer : TypeAlias = NDArray[Any]
|
||||||
|
|
||||||
|
LibraryOptions : TypeAlias = Dict[str, Any]
|
||||||
|
LibrarySet : TypeAlias = Dict[str, LibraryOptions]
|
||||||
|
|
||||||
ExecutionProvider = Literal['cuda', 'tensorrt', 'rocm', 'migraphx', 'coreml', 'openvino', 'qnn', 'directml', 'cpu']
|
ExecutionProvider = Literal['cuda', 'tensorrt', 'rocm', 'migraphx', 'coreml', 'openvino', 'qnn', 'directml', 'cpu']
|
||||||
ExecutionProviderValue = Literal['CPUExecutionProvider', 'CoreMLExecutionProvider', 'CUDAExecutionProvider', 'DmlExecutionProvider', 'OpenVINOExecutionProvider', 'MIGraphXExecutionProvider', 'QNNExecutionProvider', 'ROCMExecutionProvider', 'TensorrtExecutionProvider']
|
ExecutionProviderValue = Literal['CPUExecutionProvider', 'CoreMLExecutionProvider', 'CUDAExecutionProvider', 'DmlExecutionProvider', 'OpenVINOExecutionProvider', 'MIGraphXExecutionProvider', 'QNNExecutionProvider', 'ROCMExecutionProvider', 'TensorrtExecutionProvider']
|
||||||
ExecutionProviderSet : TypeAlias = Dict[ExecutionProvider, ExecutionProviderValue]
|
ExecutionProviderSet : TypeAlias = Dict[ExecutionProvider, ExecutionProviderValue]
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ def test_stream_image(test_client : TestClient) -> None:
|
|||||||
output_bytes = websocket.receive_bytes()
|
output_bytes = websocket.receive_bytes()
|
||||||
output_vision_frame = cv2.imdecode(numpy.frombuffer(output_bytes, numpy.uint8), cv2.IMREAD_COLOR)
|
output_vision_frame = cv2.imdecode(numpy.frombuffer(output_bytes, numpy.uint8), cv2.IMREAD_COLOR)
|
||||||
|
|
||||||
|
# TODO: can we test if bytes have been passed? what does this actual test than just the handshake?
|
||||||
|
# TODO: compare to the video test - no status code check?
|
||||||
assert output_vision_frame.shape == (1024, 1024, 3)
|
assert output_vision_frame.shape == (1024, 1024, 3)
|
||||||
|
|
||||||
|
|
||||||
@@ -144,6 +146,7 @@ def test_stream_video(test_client : TestClient) -> None:
|
|||||||
'Content-Type': 'application/sdp'
|
'Content-Type': 'application/sdp'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# TODO: can we test if bytes have been passed? what does this actual test than just the handshake?
|
||||||
assert stream_response.status_code == 201
|
assert stream_response.status_code == 201
|
||||||
assert stream_response.text
|
assert stream_response.text
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user