Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
def faceSwap(file1, file2): | |
# Process the uploaded files (e.g., read content, perform calculations, etc.) | |
# Replace the following lines with your actual processing logic | |
#file1_content = file1.read().decode("utf-8") | |
#file2_content = file2.read().decode("utf-8") | |
#result = f"File 1 content:\n{file1_content}\n\nFile 2 content:\n{file2_content}" | |
#result = "It worked" | |
#FaceSwap Stuff | |
url = "https://api.prodia.com/v1/faceswap" | |
payload = { | |
"sourceUrl": file1, | |
"targetUrl": file2 | |
} | |
headers = { | |
"accept": "application/json", | |
"content-type": "application/json" | |
} | |
response = requests.post(url, json=payload, headers=headers) | |
print(response.text) | |
urlBase = "https://api.prodia.com/v1/job/" | |
headers = {"accept": "application/json"} | |
response = requests.get(urlBase + jobNumber, headers=headers) | |
result = print(response.imageURL) | |
return result | |
# Create a Gradio interface with two file upload components | |
iface = gr.Interface( | |
fn=faceSwap, | |
inputs=[ | |
# gr.inputs.File(label="Upload File 1"), | |
# gr.inputs.File(label="Upload File 2") | |
gr.Image(label="Face File", value="FaceFile", interactive=True, show_share_button=True, container=True, type='filepath', sources=('upload', 'webcam', 'clipboard')), | |
gr.Image(label="Body File", value="BodyFile", interactive=True, show_share_button=True, container=True, type='filepath', sources=('upload', 'webcam', 'clipboard')) | |
], | |
outputs=[ | |
gr.Image(type="pil", show_download_button=True), | |
gr.Image(type="pil", show_download_button=True) | |
], | |
#gr.Textbox(label="Job Number", placeholder="will fill in when job number received", interactive=False), | |
title="File Upload Interface", | |
description="Upload two files and process them." | |
) | |
# Launch the Gradio interface | |
iface.launch() | |