|
import gradio as gr |
|
import modules.globals |
|
import modules.processors.frame.core as frame_processor |
|
import modules.utilities as utilities |
|
import cv2 |
|
import os |
|
|
|
def process_image(source_image, target_image): |
|
modules.globals.source_path = utilities.save_temp_image(source_image) |
|
modules.globals.target_path = utilities.save_temp_image(target_image) |
|
modules.globals.output_path = "output.png" |
|
|
|
frame_processor.process_image(modules.globals.source_path, modules.globals.target_path, modules.globals.output_path) |
|
|
|
return modules.globals.output_path |
|
|
|
iface = gr.Interface( |
|
fn=process_image, |
|
inputs=[ |
|
gr.Image(type="numpy", label="Source Image"), |
|
gr.Image(type="numpy", label="Target Image") |
|
], |
|
outputs=gr.Image(type="filepath", label="Output Image"), |
|
title="Face Swapper", |
|
description="Upload a source face and a target image to swap faces.", |
|
flagging_dir="/app/flagged" |
|
) |
|
|
|
iface.launch() |