Update model set and stuff and here is the py script that we are modifying from argparse…
- User
Update model set and stuff and here is the py script that we are modifying from argparse import ArgumentParser from typing import List, Tuple
import cv2 import numpy
import facefusion.jobs.job_manager import facefusion.jobs.job_store import facefusion.processors.core as processors from facefusion import config, content_analyser, face_classifier, face_detector, face_landmarker, face_masker, face_recognizer, inference_manager, logger, process_manager, state_manager, wording from facefusion.download import conditional_download_hashes, conditional_download_sources from facefusion.face_analyser import get_many_faces, get_one_face from facefusion.face_helper import paste_back, warp_face_by_face_landmark_5 from facefusion.face_masker import create_occlusion_mask, create_static_box_mask from facefusion.face_selector import find_similar_faces, sort_and_filter_faces from facefusion.face_store import get_reference_faces from facefusion.filesystem import in_directory, is_image, is_video, resolve_relative_path, same_file_extension from facefusion.processors import choices as processors_choices from facefusion.processors.typing import DeepSwapperInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import thread_semaphore from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, Mask, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import adaptive_match_frame_color, read_image, read_static_image, write_image
MODEL_SET : ModelSet =
{ 'jackie_chan': { 'hashes': { 'deep_swapper': { 'url': 'https://huggingface.co/bluefoxcreation/DFM/resolve/main/Jackie_Chan.hash', 'path': resolve_relative_path('../.assets/models/Jackie_Chan.hash') } }, 'sources': { 'deep_swapper': { 'url': 'https://github.com/iperov/DeepFaceLive/releases/download/JACKIE_CHAN/Jackie_Chan.dfm', 'path': resolve_relative_path('../.assets/models/Jackie_Chan.dfm') } }, 'template': 'arcface_128_v2', 'size': (224, 224) } }def get_inference_pool() -> InferencePool: model_sources = get_model_options().get('sources') model_context = name + '.' + state_manager.get_item('deep_swapper_model') return inference_manager.get_inference_pool(model_context, model_sources)
def clear_inference_pool() -> None: model_context = name + '.' + state_manager.get_item('deep_swapper_model') inference_manager.clear_inference_pool(model_context)
def get_model_options() -> ModelOptions: deep_swapper_model = state_manager.get_item('deep_swapper_model') return MODEL_SET.get(deep_swapper_model)
def register_args(program : ArgumentParser) -> None: group_processors = find_argument_group(program, 'processors') if group_processors: group_processors.add_argument('--deep-swapper-model', help = wording.get('help.deep_swapper_model'), default = config.get_str_value('processors.deep_swapper_model', 'jackie_chan'), choices = processors_choices.deep_swapper_models) facefusion.jobs.job_store.register_step_keys([ 'deep_swapper_model' ])
- Assistant
You've shared a Python script for a face-swapping application that utilizes a deep learning model for performing facial transformations. Based on the context you've provided, could you clarify what modifications or updates you're looking to implement in this script?
Here are a few areas that are commonly updated in such scripts:
-
Adding New Models: If you want to add new face-swapping models, this would involve expanding the
MODEL_SET. -
Updating Model URLs: If existing models have new URLs for their hashes or data files, you'll need to update those within the
MODEL_SET. -
Enhancing Processing Logic: Changes might be needed in the
process_framefunction or others to improve the swapping quality or incorporate other facial features. -
Error Handling and Logging: You might want to enhance error handling or improve logging messages.
-
- User
- Assistant