import gradio as gr from prodiapy import Prodia from PIL import Image from io import BytesIO import requests import base64 client = Prodia() def run_face_swap(source_image, target_image): if source_image is None or target_image is None: return print(source_image, target_image) return "https://images.prodia.xyz/acfe8b01-b706-46d9-8c2d-287466337609.png" def image_to_base64(image: Image): # Convert the image to bytes buffered = BytesIO() image.save(buffered, format="PNG") # You can change format to PNG if needed # Encode the bytes to base64 img_str = base64.b64encode(buffered.getvalue()) return img_str.decode('utf-8') # Convert bytes to string with gr.Blocks() as demo: with gr.Column(): gr.HTML("

Face Swap

") gr.DuplicateButton(size="lg") with gr.Row(): with gr.Column(): source_image = gr.Image(type="filepath", label="Source Image") target_image = gr.Image(type="filepath", label="Target Image") with gr.Column(): run_button = gr.Button("Swap Faces", variant="primary") result = gr.Image() run_button.click(fn=run_face_swap, inputs=[source_image, target_image], outputs=result) demo.launch(show_api=False)