in2IN / app.py
pabloruizponce's picture
Update app.py
415515a verified
raw
history blame
1.44 kB
import gradio as gr
import torch
from in2in.utils.plot import plot_3d_motion
from in2in.utils.paramUtil import HML_KINEMATIC_CHAIN
from transformers import AutoModel
import random
import string
def generate_random_filename(length=10, extension='.mp4'):
"""
Generates a random file name with the specified length and file extension.
Args:
length (int): The desired length of the file name (excluding the extension).
extension (str): The file extension, including the dot (e.g., '.txt', '.jpg', '.pdf').
Returns:
str: The generated random file name with the specified extension.
"""
characters = string.ascii_letters + string.digits
filename = ''.join(random.choice(characters) for _ in range(length))
return filename + extension
def generate(textI, texti1, texti2):
preds = model(textI, texti1, texti2)
filename = generate_random_filename(length=15, extension='.mp4')
plot_3d_motion(filename, HML_KINEMATIC_CHAIN, preds, title="", fps=30)
return filename
model = AutoModel.from_pretrained("pabloruizponce/in2IN", trust_remote_code=True)
model.to("cuda")
demo = gr.Interface(fn=generate,
inputs=[gr.Text(label="Interaction Description"),
gr.Text(label="Individual1 Description"),
gr.Text(label="Individual2 Description")],
outputs=gr.Video())
demo.launch()