import gradio as gr import subprocess import os def greet(name, image): # Specify the path to the run.py script script_path = "run.py" # Specify the paths for the image, video, and output image_path = "uploaded_image.jpg" video_path = "video.mp4" output_path = "output.mp4" # Save the uploaded image with the appropriate file extension #image_extension = os.path.splitext(image_path)[-1].lower() #image.save(image_path, format=image_extension.lstrip('.').upper()) # Construct the command to execute the run.py script with the specified arguments command = f"python {script_path} -s {image} -t {video_path} -o {output_path}" # Execute the command using subprocess subprocess.run(command, shell=True) # Return the output video as a gradio Image object #return gr.outputs.Video(file_path=output_path), "" return output_path, "" iface = gr.Interface(fn=greet, inputs=["text", gr.inputs.Image(type="pil")], outputs=["video", "text"]) iface.launch()