feat: add API process functionality

This commit adds comprehensive API process functionality including:
- Remote streaming support
- Session management and context handling
- Media type support (video/audio/image)
- Asset management and path isolation
- Workflow refactoring and optimization
- Security improvements and state violation handling
- Gallery and image resolution features
- Audio support
- Analysis tools
- Version guard

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
henryruhs
2025-12-20 14:35:07 +01:00
parent bed330f701
commit 423fee9d7f
82 changed files with 3424 additions and 806 deletions
+3 -7
View File
@@ -1,7 +1,7 @@
import os
import tempfile
from facefusion.filesystem import are_images, create_directory, is_directory, is_file, remove_directory, resolve_file_paths
from facefusion.filesystem import create_directory, is_directory, is_file, remove_directory
from facefusion.types import JobStatus
@@ -26,14 +26,10 @@ def get_test_examples_directory() -> str:
def is_test_output_file(file_path : str) -> bool:
return is_file(get_test_output_path(file_path))
return is_file(get_test_output_file(file_path))
def is_test_output_sequence(directory_path : str) -> bool:
return are_images(resolve_file_paths(directory_path))
def get_test_output_path(file_path : str) -> str:
def get_test_output_file(file_path : str) -> str:
return os.path.join(get_test_outputs_directory(), file_path)
+303
View File
@@ -0,0 +1,303 @@
import io
from typing import Iterator
import pytest
from starlette.testclient import TestClient
from facefusion import metadata, session_manager, state_manager
from facefusion.apis.core import create_api
@pytest.fixture(scope = 'module')
def test_client() -> Iterator[TestClient]:
with TestClient(create_api()) as test_client:
yield test_client
@pytest.fixture(scope = 'function', autouse = True)
def before_each() -> None:
session_manager.SESSIONS.clear()
state_manager.clear_item('asset_registry')
@pytest.fixture(scope = 'function')
def auth_token(test_client : TestClient) -> str:
create_session_response = test_client.post('/session', json =
{
'client_version': metadata.get('version')
})
return create_session_response.json().get('access_token')
def test_upload_source_single(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
test_image.name = 'test_face.jpg'
response = test_client.post('/assets?type=source',
files = {'file': ('test_face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 201
body = response.json()
assert body.get('message') == '1 source(s) uploaded successfully'
assert len(body.get('asset_ids')) == 1
assert isinstance(body.get('asset_ids')[0], str)
def test_upload_source_multiple(test_client : TestClient, auth_token : str) -> None:
test_image1 = io.BytesIO(b'fake image data 1')
test_image1.name = 'face1.jpg'
test_image2 = io.BytesIO(b'fake image data 2')
test_image2.name = 'face2.jpg'
response = test_client.post('/assets?type=source',
files = [
('file', ('face1.jpg', test_image1, 'image/jpeg')),
('file', ('face2.jpg', test_image2, 'image/jpeg'))
],
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 201
body = response.json()
assert body.get('message') == '2 source(s) uploaded successfully'
assert len(body.get('asset_ids')) == 2
def test_upload_target_image(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
test_image.name = 'target.jpg'
response = test_client.post('/assets?type=target',
files = {'file': ('target.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 201
body = response.json()
assert body.get('message') == 'Target uploaded successfully'
assert isinstance(body.get('asset_id'), str)
def test_upload_missing_type_param(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
response = test_client.post('/assets',
files = {'file': ('test.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 400
assert response.json().get('message') == 'Missing required query parameter: type'
def test_upload_invalid_type_param(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
response = test_client.post('/assets?type=invalid',
files = {'file': ('test.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 400
assert response.json().get('message') == 'Invalid type. Must be "source" or "target"'
def test_upload_no_file(test_client : TestClient, auth_token : str) -> None:
response = test_client.post('/assets?type=source',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 400
assert response.json().get('message') == 'No file provided'
def test_list_assets_empty(test_client : TestClient, auth_token : str) -> None:
response = test_client.get('/assets',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
body = response.json()
assert body.get('count') == 0
assert body.get('assets') == []
def test_list_assets_with_uploads(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
test_image2 = io.BytesIO(b'fake target data')
test_client.post('/assets?type=target',
files = {'file': ('target.jpg', test_image2, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
response = test_client.get('/assets',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
body = response.json()
assert body.get('count') == 2
assets = body.get('assets')
assert len(assets) == 2
def test_list_assets_filter_by_type(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
test_image2 = io.BytesIO(b'fake target data')
test_client.post('/assets?type=target',
files = {'file': ('target.jpg', test_image2, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
response = test_client.get('/assets?type=source',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
body = response.json()
assert body.get('count') == 1
assets = body.get('assets')
assert assets[0].get('type') == 'source'
def test_get_asset_metadata(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
upload_response = test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
asset_id = upload_response.json().get('asset_ids')[0]
response = test_client.get(f'/assets/{asset_id}',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
body = response.json()
assert body.get('id') == asset_id
assert body.get('type') == 'source'
assert body.get('filename') == 'face.jpg'
assert body.get('size') > 0
assert body.get('created_at')
assert 'path' not in body
def test_get_asset_not_found(test_client : TestClient, auth_token : str) -> None:
response = test_client.get('/assets/non-existent-id',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 404
assert response.json().get('message') == 'Asset not found'
def test_download_asset(test_client : TestClient, auth_token : str) -> None:
test_data = b'fake image data for download'
test_image = io.BytesIO(test_data)
upload_response = test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
asset_id = upload_response.json().get('asset_ids')[0]
response = test_client.get(f'/assets/{asset_id}?action=download',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
assert response.content == test_data
def test_download_asset_not_found(test_client : TestClient, auth_token : str) -> None:
response = test_client.get('/assets/non-existent-id?action=download',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 404
assert response.json().get('message') == 'Asset not found'
def test_delete_asset(test_client : TestClient, auth_token : str) -> None:
test_image = io.BytesIO(b'fake image data')
upload_response = test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {auth_token}'}
)
asset_id = upload_response.json().get('asset_ids')[0]
response = test_client.delete(f'/assets/{asset_id}',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 200
assert response.json().get('message') == 'Asset deleted successfully'
get_response = test_client.get(f'/assets/{asset_id}',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert get_response.status_code == 404
def test_delete_asset_not_found(test_client : TestClient, auth_token : str) -> None:
response = test_client.delete('/assets/non-existent-id',
headers = {'Authorization': f'Bearer {auth_token}'}
)
assert response.status_code == 404
assert response.json().get('message') == 'Asset not found'
def test_assets_require_auth(test_client : TestClient) -> None:
response = test_client.get('/assets')
assert response.status_code == 401
response = test_client.post('/assets?type=source')
assert response.status_code == 401
response = test_client.get('/assets/some-id')
assert response.status_code == 401
response = test_client.delete('/assets/some-id')
assert response.status_code == 401
def test_assets_session_isolation(test_client : TestClient) -> None:
session1_response = test_client.post('/session', json = {'client_version': metadata.get('version')})
session1_token = session1_response.json().get('access_token')
session2_response = test_client.post('/session', json = {'client_version': metadata.get('version')})
session2_token = session2_response.json().get('access_token')
test_image = io.BytesIO(b'session 1 data')
upload_response = test_client.post('/assets?type=source',
files = {'file': ('face.jpg', test_image, 'image/jpeg')},
headers = {'Authorization': f'Bearer {session1_token}'}
)
asset_id = upload_response.json().get('asset_ids')[0]
response = test_client.get('/assets',
headers = {'Authorization': f'Bearer {session1_token}'}
)
assert response.json().get('count') == 1
response = test_client.get('/assets',
headers = {'Authorization': f'Bearer {session2_token}'}
)
assert response.json().get('count') == 0
response = test_client.get(f'/assets/{asset_id}',
headers = {'Authorization': f'Bearer {session2_token}'}
)
assert response.status_code == 404
+247
View File
@@ -0,0 +1,247 @@
import os
import tempfile
from typing import Iterator
import pytest
from facefusion import asset_store, session_manager, state_manager
from facefusion.session_context import clear_session_id, set_session_id
@pytest.fixture(scope = 'function', autouse = True)
def before_each() -> None:
session_manager.SESSIONS.clear()
state_manager.clear_item('asset_registry')
clear_session_id()
@pytest.fixture(scope = 'function')
def temp_file() -> Iterator[str]:
fd, path = tempfile.mkstemp(suffix = '.jpg')
os.write(fd, b'test file content')
os.close(fd)
yield path
if os.path.exists(path):
os.remove(path)
@pytest.fixture(scope = 'function')
def session_id() -> str:
test_session_id = 'test-session-123'
set_session_id(test_session_id)
return test_session_id
def test_register_source_asset(temp_file : str, session_id : str) -> None:
asset_id = asset_store.register('source', temp_file, 'test.jpg')
assert isinstance(asset_id, str)
assert len(asset_id) == 36
asset = asset_store.get_asset(asset_id)
assert asset is not None
assert asset.get('id') == asset_id
assert asset.get('session_id') == session_id
assert asset.get('type') == 'source'
assert asset.get('path') == temp_file
assert asset.get('filename') == 'test.jpg'
assert asset.get('size') > 0
assert asset.get('created_at')
def test_register_target_asset(temp_file : str, session_id : str) -> None:
asset_id = asset_store.register('target', temp_file, 'video.mp4')
asset = asset_store.get_asset(asset_id)
assert asset.get('type') == 'target'
assert asset.get('filename') == 'video.mp4'
def test_register_output_asset(temp_file : str, session_id : str) -> None:
metadata = {'fps': 30, 'resolution': [1920, 1080]}
asset_id = asset_store.register('output', temp_file, 'output.mp4', metadata)
asset = asset_store.get_asset(asset_id)
assert asset.get('type') == 'output'
assert asset.get('metadata') == metadata
def test_register_invalid_type(temp_file : str, session_id : str) -> None:
with pytest.raises(ValueError) as exc:
asset_store.register('invalid_type', temp_file, 'test.jpg')
assert "Invalid asset_type" in str(exc.value)
def test_register_without_session() -> None:
fd, path = tempfile.mkstemp()
os.close(fd)
try:
with pytest.raises(ValueError) as exc:
asset_store.register('source', path, 'test.jpg')
assert "No active session" in str(exc.value)
finally:
os.remove(path)
def test_register_without_filename(temp_file : str, session_id : str) -> None:
asset_id = asset_store.register('source', temp_file)
asset = asset_store.get_asset(asset_id)
assert asset.get('filename') == os.path.basename(temp_file)
def test_get_asset_not_found(session_id : str) -> None:
asset = asset_store.get_asset('non-existent-id')
assert asset is None
def test_list_assets_empty(session_id : str) -> None:
assets = asset_store.list_assets()
assert assets == []
def test_list_assets_with_multiple(temp_file : str, session_id : str) -> None:
fd1, path1 = tempfile.mkstemp(suffix = '.jpg')
os.write(fd1, b'content 1')
os.close(fd1)
fd2, path2 = tempfile.mkstemp(suffix = '.mp4')
os.write(fd2, b'content 2')
os.close(fd2)
try:
asset_store.register('source', path1, 'source1.jpg')
asset_store.register('source', path2, 'source2.jpg')
asset_store.register('target', temp_file, 'target.mp4')
assets = asset_store.list_assets()
assert len(assets) == 3
finally:
os.remove(path1)
os.remove(path2)
def test_list_assets_filter_by_type(temp_file : str, session_id : str) -> None:
fd, path = tempfile.mkstemp(suffix = '.jpg')
os.write(fd, b'content')
os.close(fd)
try:
asset_store.register('source', path, 'source.jpg')
asset_store.register('target', temp_file, 'target.mp4')
source_assets = asset_store.list_assets('source')
assert len(source_assets) == 1
assert source_assets[0].get('type') == 'source'
target_assets = asset_store.list_assets('target')
assert len(target_assets) == 1
assert target_assets[0].get('type') == 'target'
output_assets = asset_store.list_assets('output')
assert len(output_assets) == 0
finally:
os.remove(path)
def test_list_assets_invalid_type(session_id : str) -> None:
with pytest.raises(ValueError) as exc:
asset_store.list_assets('invalid_type')
assert "Invalid asset_type" in str(exc.value)
def test_list_assets_session_scoped(temp_file : str) -> None:
session1_id = 'session-1'
set_session_id(session1_id)
asset1_id = asset_store.register('source', temp_file, 'file1.jpg')
session2_id = 'session-2'
set_session_id(session2_id)
fd, path2 = tempfile.mkstemp(suffix = '.jpg')
os.write(fd, b'content 2')
os.close(fd)
try:
asset2_id = asset_store.register('source', path2, 'file2.jpg')
assets_session2 = asset_store.list_assets()
assert len(assets_session2) == 1
assert assets_session2[0].get('id') == asset2_id
set_session_id(session1_id)
assets_session1 = asset_store.list_assets()
assert len(assets_session1) == 1
assert assets_session1[0].get('id') == asset1_id
finally:
os.remove(path2)
def test_delete_asset(temp_file : str, session_id : str) -> None:
asset_id = asset_store.register('source', temp_file, 'test.jpg')
assert os.path.exists(temp_file)
success = asset_store.delete_asset(asset_id)
assert success is True
assert not os.path.exists(temp_file)
asset = asset_store.get_asset(asset_id)
assert asset is None
def test_delete_asset_not_found(session_id : str) -> None:
success = asset_store.delete_asset('non-existent-id')
assert success is False
def test_cleanup_session_assets(session_id : str) -> None:
fd1, path1 = tempfile.mkstemp(suffix = '.jpg')
os.write(fd1, b'content 1')
os.close(fd1)
fd2, path2 = tempfile.mkstemp(suffix = '.mp4')
os.write(fd2, b'content 2')
os.close(fd2)
asset_id1 = asset_store.register('source', path1, 'source.jpg')
asset_id2 = asset_store.register('target', path2, 'target.mp4')
assert os.path.exists(path1)
assert os.path.exists(path2)
asset_store.cleanup_session_assets(session_id)
assert not os.path.exists(path1)
assert not os.path.exists(path2)
assert asset_store.get_asset(asset_id1) is None
assert asset_store.get_asset(asset_id2) is None
def test_cleanup_session_assets_only_affects_target_session(temp_file : str) -> None:
session1_id = 'session-1'
set_session_id(session1_id)
fd, path1 = tempfile.mkstemp(suffix = '.jpg')
os.write(fd, b'content 1')
os.close(fd)
asset1_id = asset_store.register('source', path1, 'file1.jpg')
session2_id = 'session-2'
set_session_id(session2_id)
asset2_id = asset_store.register('source', temp_file, 'file2.jpg')
asset_store.cleanup_session_assets(session1_id)
assert not os.path.exists(path1)
assert os.path.exists(temp_file)
set_session_id(session1_id)
assert asset_store.get_asset(asset1_id) is None
set_session_id(session2_id)
assert asset_store.get_asset(asset2_id) is not None
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -25,21 +25,14 @@ def before_each() -> None:
def test_modify_age_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-age-face-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-age-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-age-face-to-image.jpg') is True
def test_modify_age_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-age-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-age-face-to-video.mp4') is True
def test_modify_age_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-age-face-to-video-as-frames')) is True
+4 -11
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -15,7 +15,7 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ])
subprocess.run(['ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg')])
@pytest.fixture(scope = 'function', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_remove_background_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-remove-background-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-remove-background-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-remove-background-to-image.jpg') is True
def test_remove_background_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-remove-background-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-remove-background-to-video.mp4') is True
def test_remove_background_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-remove-background-to-video-as-frames')) is True
+3 -3
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,7 +26,7 @@ def before_each() -> None:
def test_batch_run_targets() -> None:
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-targets-{index}.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-targets-{index}.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-batch-run-targets-0.jpg') is True
@@ -35,7 +35,7 @@ def test_batch_run_targets() -> None:
def test_batch_run_sources_to_targets() -> None:
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-sources-to-targets-{index}.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-sources-to-targets-{index}.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-batch-run-sources-to-targets-0.jpg') is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -25,21 +25,14 @@ def before_each() -> None:
def test_restore_expression_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-restore-expression-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-restore-expression-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-restore-expression-to-image.jpg') is True
def test_restore_expression_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-restore-expression-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-restore-expression-to-video.mp4') is True
def test_restore_expression_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-restore-expression-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_debug_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-debug-face-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-debug-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-debug-face-to-image.jpg') is True
def test_debug_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-debug-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-debug-face-to-video.mp4') is True
def test_debug_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-debug-face-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_edit_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-edit-face-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-edit-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-image.jpg') is True
def test_edit_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-edit-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-video.mp4') is True
def test_edit_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-edit-face-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_enhance_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-face-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-enhance-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-face-to-image.jpg') is True
def test_enhance_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-enhance-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-face-to-video.mp4') is True
def test_enhance_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-enhance-face-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_swap_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-swap-face-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-swap-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-swap-face-to-image.jpg') is True
def test_swap_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-swap-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-swap-face-to-video.mp4') is True
def test_swap_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-swap-face-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -27,21 +27,14 @@ def before_each() -> None:
def test_colorize_frame_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.jpg'), '-o', get_test_output_path('test_colorize-frame-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.jpg'), '-o', get_test_output_file('test_colorize-frame-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_colorize-frame-to-image.jpg') is True
def test_colorize_frame_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_file('test-colorize-frame-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-colorize-frame-to-video.mp4') is True
def test_colorize_frame_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-colorize-frame-to-video-as-frames')) is True
+3 -10
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -26,21 +26,14 @@ def before_each() -> None:
def test_enhance_frame_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-frame-to-image.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-enhance-frame-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-frame-to-image.jpg') is True
def test_enhance_frame_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-enhance-frame-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-frame-to-video.mp4') is True
def test_enhance_frame_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-enhance-frame-to-video-as-frames')) is True
+15 -15
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, count_step_total, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_job_file
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_job_file
@pytest.fixture(scope = 'module', autouse = True)
@@ -50,7 +50,7 @@ def test_job_submit() -> None:
assert subprocess.run(commands).returncode == 1
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-submit', 'test-job-submit', '--jobs-path', get_test_jobs_directory() ]
@@ -73,10 +73,10 @@ def test_submit_all() -> None:
assert subprocess.run(commands).returncode == 1
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-2', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-2', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-submit-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
@@ -122,7 +122,7 @@ def test_job_delete_all() -> None:
def test_job_add_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-add-step') == 0
@@ -130,14 +130,14 @@ def test_job_add_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-add-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-add-step') == 1
def test_job_remix() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-remix-step') == 0
@@ -145,23 +145,23 @@ def test_job_remix() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remix-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remix-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remix-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert count_step_total('test-job-remix-step') == 1
assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-remix-step') == 2
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-remix-step') == 3
def test_job_insert_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-insert-step') == 0
@@ -169,16 +169,16 @@ def test_job_insert_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-insert-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-insert-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-insert-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert count_step_total('test-job-insert-step') == 1
assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-insert-step') == 2
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-insert-step') == 3
@@ -192,7 +192,7 @@ def test_job_remove_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remove-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remove-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remove-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-remix-step.jpg') ]
subprocess.run(commands)
subprocess.run(commands)
+9 -9
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs, move_job_file, set_steps_status
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -33,7 +33,7 @@ def test_job_run() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-run.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-run', 'test-job-run', '--jobs-path', get_test_jobs_directory() ]
@@ -61,13 +61,13 @@ def test_job_run_all() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run-all-2', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run-all-1.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-run-all-1.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-job-run-all-2.mp4'), '--trim-frame-end', '1' ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-job-run-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-run-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
@@ -93,7 +93,7 @@ def test_job_retry() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-retry.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-retry', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ]
@@ -121,13 +121,13 @@ def test_job_retry_all() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry-all-2', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry-all-1.jpg') ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-job-retry-all-1.jpg') ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-job-retry-all-2.mp4'), '--trim-frame-end', '1' ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-job-retry-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-retry-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
+3 -17
View File
@@ -5,7 +5,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -27,28 +27,14 @@ def before_each() -> None:
def test_sync_lip_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'audio-to-image:video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image.mp4') ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'audio-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test_sync_lip_to_image.mp4') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_sync_lip_to_image.mp4') is True
def test_sync_lip_to_image_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'audio-to-image:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image_as_frames') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_image_as_frames')) is True
def test_sync_lip_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video.mp4'), '--trim-frame-end', '1' ]
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test_sync_lip_to_video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_sync_lip_to_video.mp4') is True
def test_sync_lip_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video_as_frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_video_as_frames')) is True
+3 -3
View File
@@ -7,7 +7,7 @@ from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs
from facefusion.types import Resolution, Scale
from facefusion.vision import detect_image_resolution, detect_video_resolution
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -35,7 +35,7 @@ def before_each() -> None:
(8.0, (3408, 1808))
])
def test_output_image_scale(output_image_scale : Scale, output_image_resolution : Resolution) -> None:
output_file_path = get_test_output_path('test-output-image-scale-' + str(output_image_scale) + '.jpg')
output_file_path = get_test_output_file('test-output-image-scale-' + str(output_image_scale) + '.jpg')
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', output_file_path, '--output-image-scale', str(output_image_scale) ]
assert subprocess.run(commands).returncode == 0
@@ -50,7 +50,7 @@ def test_output_image_scale(output_image_scale : Scale, output_image_resolution
(8.0, (3408, 1808))
])
def test_output_video_scale(output_video_scale : Scale, output_video_resolution : Resolution) -> None:
output_file_path = get_test_output_path('test-output-video-scale-' + str(output_video_scale) + '.mp4')
output_file_path = get_test_output_file('test-output-video-scale-' + str(output_video_scale) + '.mp4')
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', output_file_path, '--trim-frame-end', '1', '--output-video-scale', str(output_video_scale) ]
assert subprocess.run(commands).returncode == 0
+2 -5
View File
@@ -1,7 +1,7 @@
from shutil import which
from facefusion import metadata
from facefusion.curl_builder import chain, ping, run, set_timeout
from facefusion.curl_builder import chain, head, run
def test_run() -> None:
@@ -11,7 +11,4 @@ def test_run() -> None:
def test_chain() -> None:
assert chain(
ping(metadata.get('url')),
set_timeout(5)
) == [ '-I', metadata.get('url'), '--connect-timeout', '5' ]
assert chain(head(metadata.get('url'))) == [ '-I', metadata.get('url') ]
+24 -24
View File
@@ -11,7 +11,7 @@ from facefusion.ffmpeg import concat_video, extract_frames, merge_video, read_au
from facefusion.filesystem import copy_file
from facefusion.temp_helper import clear_temp_directory, create_temp_directory, get_temp_file_path, resolve_temp_frame_paths
from facefusion.types import EncoderSet
from .helper import get_test_example_file, get_test_examples_directory, get_test_output_path, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -112,13 +112,13 @@ def test_spawn_frames() -> None:
def test_merge_video() -> None:
test_set =\
[
(get_test_example_file('target-240p-16khz.avi'), get_test_output_path('test-merge-video-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_path('test-merge-video-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_path('test-merge-video-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_path('test-merge-video-240p-16khz.mp4')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_path('test-merge-video-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_path('test-merge-video-240p-16khz.webm')),
(get_test_example_file('target-240p-16khz.wmv'), get_test_output_path('test-merge-video-240p-16khz.wmv'))
(get_test_example_file('target-240p-16khz.avi'), get_test_output_file('test-merge-video-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_file('test-merge-video-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_file('test-merge-video-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_file('test-merge-video-240p-16khz.mp4')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_file('test-merge-video-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_file('test-merge-video-240p-16khz.webm')),
(get_test_example_file('target-240p-16khz.wmv'), get_test_output_file('test-merge-video-240p-16khz.wmv'))
]
output_video_encoders = get_available_encoder_set().get('video')
@@ -138,7 +138,7 @@ def test_merge_video() -> None:
def test_concat_video() -> None:
output_path = get_test_output_path('test-concat-video.mp4')
output_path = get_test_output_file('test-concat-video.mp4')
temp_output_paths =\
[
get_test_example_file('target-240p-16khz.mp4'),
@@ -157,14 +157,14 @@ def test_read_audio_buffer() -> None:
def test_restore_audio() -> None:
test_set =\
[
(get_test_example_file('target-240p-16khz.avi'), get_test_output_path('target-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_path('target-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_path('target-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_path('target-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_path('target-240p-16khz.mp4')),
(get_test_example_file('target-240p-48khz.mp4'), get_test_output_path('target-240p-48khz.mp4')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_path('target-240p-16khz.webm')),
(get_test_example_file('target-240p-16khz.wmv'), get_test_output_path('target-240p-16khz.wmv'))
(get_test_example_file('target-240p-16khz.avi'), get_test_output_file('target-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_file('target-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_file('target-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_file('target-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_file('target-240p-16khz.mp4')),
(get_test_example_file('target-240p-48khz.mp4'), get_test_output_file('target-240p-48khz.mp4')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_file('target-240p-16khz.webm')),
(get_test_example_file('target-240p-16khz.wmv'), get_test_output_file('target-240p-16khz.wmv'))
]
output_audio_encoders = get_available_encoder_set().get('audio')
@@ -185,13 +185,13 @@ def test_restore_audio() -> None:
def test_replace_audio() -> None:
test_set =\
[
(get_test_example_file('target-240p-16khz.avi'), get_test_output_path('target-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_path('target-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_path('target-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_path('target-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_path('target-240p-16khz.mp4')),
(get_test_example_file('target-240p-48khz.mp4'), get_test_output_path('target-240p-48khz.mp4')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_path('target-240p-16khz.webm'))
(get_test_example_file('target-240p-16khz.avi'), get_test_output_file('target-240p-16khz.avi')),
(get_test_example_file('target-240p-16khz.m4v'), get_test_output_file('target-240p-16khz.m4v')),
(get_test_example_file('target-240p-16khz.mkv'), get_test_output_file('target-240p-16khz.mkv')),
(get_test_example_file('target-240p-16khz.mov'), get_test_output_file('target-240p-16khz.mov')),
(get_test_example_file('target-240p-16khz.mp4'), get_test_output_file('target-240p-16khz.mp4')),
(get_test_example_file('target-240p-48khz.mp4'), get_test_output_file('target-240p-48khz.mp4')),
(get_test_example_file('target-240p-16khz.webm'), get_test_output_file('target-240p-16khz.webm'))
]
output_audio_encoders = get_available_encoder_set().get('audio')
+9 -52
View File
@@ -37,12 +37,6 @@ def test_submit_job() -> None:
'target_path': 'target-1.jpg',
'output_path': 'output-1.jpg'
}
args_2 =\
{
'source_path': 'source-2.jpg',
'target_path': 'target-2.mp4',
'output_path': 'output-sequence-2'
}
assert submit_job('job-invalid') is False
@@ -51,7 +45,6 @@ def test_submit_job() -> None:
assert submit_job('job-test-submit-job') is False
add_step('job-test-submit-job', args_1)
add_step('job-test-submit-job', args_2)
assert submit_job('job-test-submit-job') is True
assert submit_job('job-test-submit-job') is False
@@ -177,18 +170,6 @@ def test_add_step() -> None:
'target_path': 'target-2.jpg',
'output_path': 'output-2.jpg'
}
args_3 =\
{
'source_path': 'source-3.jpg',
'target_path': 'target-3.mp4',
'output_path': 'output-sequence-1'
}
args_4 =\
{
'source_path': 'source-4.jpg',
'target_path': 'target-4.mp4',
'output_path': 'output-sequence-1'
}
assert add_step('job-invalid', args_1) is False
@@ -196,16 +177,12 @@ def test_add_step() -> None:
assert add_step('job-test-add-step', args_1) is True
assert add_step('job-test-add-step', args_2) is True
assert add_step('job-test-add-step', args_3) is True
assert add_step('job-test-add-step', args_4) is True
steps = get_steps('job-test-add-step')
assert steps[0].get('args') == args_1
assert steps[1].get('args') == args_2
assert steps[2].get('args') == args_3
assert steps[3].get('args') == args_4
assert count_step_total('job-test-add-step') == 4
assert count_step_total('job-test-add-step') == 2
def test_remix_step() -> None:
@@ -221,40 +198,28 @@ def test_remix_step() -> None:
'target_path': 'target-2.jpg',
'output_path': 'output-2.jpg'
}
args_3 =\
{
'source_path': 'source-3.jpg',
'target_path': 'target-3.mp4',
'output_path': 'output-sequence-3'
}
assert remix_step('job-invalid', 0, args_1) is False
create_job('job-test-remix-step')
add_step('job-test-remix-step', args_1)
add_step('job-test-remix-step', args_2)
add_step('job-test-remix-step', args_3)
assert remix_step('job-test-remix-step', 99, args_1) is False
assert remix_step('job-test-remix-step', 0, args_2) is True
assert remix_step('job-test-remix-step', -1, args_2) is True
assert remix_step('job-test-remix-step', 2, args_3) is True
steps = get_steps('job-test-remix-step')
assert steps[0].get('args') == args_1
assert steps[1].get('args') == args_2
assert steps[2].get('args') == args_3
assert steps[2].get('args').get('source_path') == args_2.get('source_path')
assert steps[2].get('args').get('target_path') == get_step_output_path('job-test-remix-step', 0, args_1.get('output_path'))
assert steps[2].get('args').get('output_path') == args_2.get('output_path')
assert steps[3].get('args').get('source_path') == args_2.get('source_path')
assert steps[3].get('args').get('target_path') == get_step_output_path('job-test-remix-step', 0, args_1.get('output_path'))
assert steps[3].get('args').get('target_path') == get_step_output_path('job-test-remix-step', 2, args_2.get('output_path'))
assert steps[3].get('args').get('output_path') == args_2.get('output_path')
assert steps[4].get('args').get('source_path') == args_2.get('source_path')
assert steps[4].get('args').get('target_path') == get_step_output_path('job-test-remix-step', 3, args_2.get('output_path'))
assert steps[4].get('args').get('output_path') == args_2.get('output_path')
assert steps[5].get('args').get('source_path') == args_3.get('source_path')
assert steps[5].get('args').get('target_path') == get_step_output_path('job-test-remix-step', 2, args_3.get('output_path'))
assert steps[5].get('args').get('output_path') == args_3.get('output_path')
assert count_step_total('job-test-remix-step') == 6
assert count_step_total('job-test-remix-step') == 4
def test_insert_step() -> None:
@@ -276,12 +241,6 @@ def test_insert_step() -> None:
'target_path': 'target-3.jpg',
'output_path': 'output-3.jpg'
}
args_4 =\
{
'source_path': 'source-4.jpg',
'target_path': 'target-4.mp4',
'output_path': 'output-sequence-4'
}
assert insert_step('job-invalid', 0, args_1) is False
@@ -292,16 +251,14 @@ def test_insert_step() -> None:
assert insert_step('job-test-insert-step', 99, args_1) is False
assert insert_step('job-test-insert-step', 0, args_2) is True
assert insert_step('job-test-insert-step', -1, args_3) is True
assert insert_step('job-test-insert-step', 2, args_4) is True
steps = get_steps('job-test-insert-step')
assert steps[0].get('args') == args_2
assert steps[1].get('args') == args_1
assert steps[2].get('args') == args_4
assert steps[3].get('args') == args_3
assert steps[4].get('args') == args_1
assert count_step_total('job-test-insert-step') == 5
assert steps[2].get('args') == args_3
assert steps[3].get('args') == args_1
assert count_step_total('job-test-insert-step') == 4
def test_remove_step() -> None:
+33 -89
View File
@@ -1,14 +1,13 @@
import os
import subprocess
import pytest
from facefusion.download import conditional_download
from facefusion.filesystem import copy_file, create_directory, get_file_extension
from facefusion.filesystem import copy_file
from facefusion.jobs.job_manager import add_step, clear_jobs, create_job, init_jobs, move_job_file, submit_job, submit_jobs
from facefusion.jobs.job_runner import collect_output_set, finalize_steps, retry_job, retry_jobs, run_job, run_jobs, run_steps
from facefusion.types import Args
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -29,15 +28,7 @@ def before_each() -> None:
def process_step(job_id : str, step_index : int, step_args : Args) -> bool:
output_path = step_args.get('output_path')
target_path = step_args.get('target_path')
if output_path and not get_file_extension(output_path):
if create_directory(output_path):
return copy_file(target_path, os.path.join(output_path, os.path.basename(target_path)))
return False
return copy_file(target_path, output_path)
return copy_file(step_args.get('target_path'), step_args.get('output_path'))
def test_run_job() -> None:
@@ -45,31 +36,19 @@ def test_run_job() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
}
args_4 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-4')
}
args_5 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-4')
'output_path': get_test_output_file('output-3.jpg')
}
assert run_job('job-invalid', process_step) is False
@@ -79,8 +58,6 @@ def test_run_job() -> None:
add_step('job-test-run-job', args_2)
add_step('job-test-run-job', args_2)
add_step('job-test-run-job', args_3)
add_step('job-test-run-job', args_4)
add_step('job-test-run-job', args_5)
assert run_job('job-test-run-job', process_step) is False
@@ -94,19 +71,19 @@ def test_run_jobs() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
'output_path': get_test_output_file('output-3.jpg')
}
halt_on_error = True
@@ -131,7 +108,7 @@ def test_retry_job() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
assert retry_job('job-invalid', process_step) is False
@@ -152,19 +129,19 @@ def test_retry_jobs() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
'output_path': get_test_output_file('output-3.jpg')
}
halt_on_error = True
@@ -190,19 +167,19 @@ def test_run_steps() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
'output_path': get_test_output_file('output-3.jpg')
}
assert run_steps('job-invalid', process_step) is False
@@ -221,31 +198,19 @@ def test_finalize_steps() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
}
args_4 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-4')
}
args_5 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-4')
'output_path': get_test_output_file('output-3.jpg')
}
create_job('job-test-finalize-steps')
@@ -253,26 +218,16 @@ def test_finalize_steps() -> None:
add_step('job-test-finalize-steps', args_1)
add_step('job-test-finalize-steps', args_2)
add_step('job-test-finalize-steps', args_3)
add_step('job-test-finalize-steps', args_4)
add_step('job-test-finalize-steps', args_5)
copy_file(args_1.get('target_path'), get_test_output_path('output-1-job-test-finalize-steps-0.mp4'))
copy_file(args_1.get('target_path'), get_test_output_path('output-1-job-test-finalize-steps-1.mp4'))
copy_file(args_2.get('target_path'), get_test_output_path('output-2-job-test-finalize-steps-2.mp4'))
copy_file(args_3.get('target_path'), get_test_output_path('output-3-job-test-finalize-steps-3.jpg'))
temp_directory_1 = get_test_output_path('output-4-job-test-finalize-steps-4')
temp_directory_2 = get_test_output_path('output-4-job-test-finalize-steps-5')
create_directory(temp_directory_1)
create_directory(temp_directory_2)
copy_file(args_4.get('target_path'), os.path.join(temp_directory_1, '00000001.jpg'))
copy_file(args_5.get('target_path'), os.path.join(temp_directory_2, '00000002.jpg'))
copy_file(args_1.get('target_path'), get_test_output_file('output-1-job-test-finalize-steps-0.mp4'))
copy_file(args_1.get('target_path'), get_test_output_file('output-1-job-test-finalize-steps-1.mp4'))
copy_file(args_2.get('target_path'), get_test_output_file('output-2-job-test-finalize-steps-2.mp4'))
copy_file(args_3.get('target_path'), get_test_output_file('output-3-job-test-finalize-steps-3.jpg'))
assert finalize_steps('job-test-finalize-steps') is True
assert is_test_output_file('output-1.mp4') is True
assert is_test_output_file('output-2.mp4') is True
assert is_test_output_file('output-3.jpg') is True
assert is_test_output_sequence(get_test_output_path('output-4')) is True
def test_collect_output_set() -> None:
@@ -280,25 +235,19 @@ def test_collect_output_set() -> None:
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-1.mp4')
'output_path': get_test_output_file('output-1.mp4')
}
args_2 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-2.mp4')
'output_path': get_test_output_file('output-2.mp4')
}
args_3 =\
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.jpg'),
'output_path': get_test_output_path('output-3.jpg')
}
args_4 = \
{
'source_path': get_test_example_file('source.jpg'),
'target_path': get_test_example_file('target-240p.mp4'),
'output_path': get_test_output_path('output-4')
'output_path': get_test_output_file('output-3.jpg')
}
create_job('job-test-collect-output-set')
@@ -306,26 +255,21 @@ def test_collect_output_set() -> None:
add_step('job-test-collect-output-set', args_1)
add_step('job-test-collect-output-set', args_2)
add_step('job-test-collect-output-set', args_3)
add_step('job-test-collect-output-set', args_4)
output_set =\
{
get_test_output_path('output-1.mp4'):
get_test_output_file('output-1.mp4'):
[
get_test_output_path('output-1-job-test-collect-output-set-0.mp4'),
get_test_output_path('output-1-job-test-collect-output-set-1.mp4')
get_test_output_file('output-1-job-test-collect-output-set-0.mp4'),
get_test_output_file('output-1-job-test-collect-output-set-1.mp4')
],
get_test_output_path('output-2.mp4'):
get_test_output_file('output-2.mp4'):
[
get_test_output_path('output-2-job-test-collect-output-set-2.mp4')
get_test_output_file('output-2-job-test-collect-output-set-2.mp4')
],
get_test_output_path('output-3.jpg'):
get_test_output_file('output-3.jpg'):
[
get_test_output_path('output-3-job-test-collect-output-set-3.jpg')
],
get_test_output_path('output-4'):
[
get_test_output_path('output-4-job-test-collect-output-set-4')
get_test_output_file('output-3-job-test-collect-output-set-3.jpg')
]
}
+6 -18
View File
@@ -1,6 +1,8 @@
from argparse import ArgumentParser
from facefusion.program_helper import find_argument_group, validate_actions, validate_args
import pytest
from facefusion.program_helper import find_argument_group, validate_actions
def test_find_argument_group() -> None:
@@ -10,26 +12,12 @@ def test_find_argument_group() -> None:
assert find_argument_group(program, 'test-1')
assert find_argument_group(program, 'test-2')
assert find_argument_group(program, 'test-3') is None
assert find_argument_group(program, 'invalid') is None
@pytest.mark.skip()
def test_validate_args() -> None:
program = ArgumentParser()
program.add_argument('--test-1', default = 'test_1', choices = [ 'test_1', 'test_2' ])
assert validate_args(program) is True
subparsers = program.add_subparsers()
sub_program = subparsers.add_parser('sub-command')
sub_program.add_argument('--test-2', default = 'test_2', choices = [ 'test_1', 'test_2' ])
assert validate_args(program) is True
for action in sub_program._actions:
if action.dest == 'test_2':
action.default = 'test_3'
assert validate_args(program) is False
pass
def test_validate_actions() -> None:
+3 -3
View File
@@ -1,11 +1,11 @@
from facefusion import translator
from facefusion.locales import LOCALES
from facefusion.locals import LOCALS
def test_load() -> None:
translator.load(LOCALES, __name__)
translator.load(LOCALS, __name__)
assert __name__ in translator.LOCALE_POOL_SET
assert __name__ in translator.LOCAL_POOL_SET
def test_get() -> None:
+3 -3
View File
@@ -4,7 +4,7 @@ import pytest
from facefusion.download import conditional_download
from facefusion.vision import calculate_histogram_difference, count_video_frame_total, detect_image_resolution, detect_video_duration, detect_video_fps, detect_video_resolution, match_frame_color, normalize_resolution, pack_resolution, predict_video_frame_total, read_image, read_video_frame, restrict_image_resolution, restrict_trim_video_frame, restrict_video_fps, restrict_video_resolution, scale_resolution, unpack_resolution, write_image
from .helper import get_test_example_file, get_test_examples_directory, get_test_output_path, prepare_test_output_directory
from .helper import get_test_example_file, get_test_examples_directory, get_test_output_file, prepare_test_output_directory
@pytest.fixture(scope = 'module', autouse = True)
@@ -42,8 +42,8 @@ def test_read_image() -> None:
def test_write_image() -> None:
vision_frame = read_image(get_test_example_file('target-240p.jpg'))
assert write_image(get_test_output_path('target-240p.jpg'), vision_frame) is True
assert write_image(get_test_output_path('目标-240p.webp'), vision_frame) is True
assert write_image(get_test_output_file('target-240p.jpg'), vision_frame) is True
assert write_image(get_test_output_file('目标-240p.webp'), vision_frame) is True
def test_detect_image_resolution() -> None: