Spaces:
Running
Running
requirements.txt
Browse filesgradio
huggingface_hub
app.py
CHANGED
|
@@ -1,55 +1,36 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import cv2
|
| 3 |
-
import numpy as np
|
| 4 |
import os
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def motion_transfer(image, video):
|
| 9 |
-
|
| 10 |
-
if image is None or video is None:
|
| 11 |
-
return None
|
| 12 |
|
| 13 |
-
|
| 14 |
-
cap = cv2.VideoCapture(video)
|
| 15 |
-
|
| 16 |
-
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 17 |
-
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 18 |
-
fps = cap.get(cv2.CAP_PROP_FPS)
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
output_path = "outputs/result.mp4"
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
ret, frame = cap.read()
|
| 30 |
-
|
| 31 |
-
if not ret:
|
| 32 |
-
break
|
| 33 |
-
|
| 34 |
-
blended = cv2.addWeighted(img, 0.7, frame, 0.3, 0)
|
| 35 |
-
|
| 36 |
-
out.write(blended)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
return output_path
|
| 42 |
|
| 43 |
|
| 44 |
app = gr.Interface(
|
| 45 |
-
fn=
|
| 46 |
inputs=[
|
| 47 |
gr.Image(type="filepath", label="Upload Image"),
|
| 48 |
-
gr.Video(label="Upload Motion Video")
|
| 49 |
],
|
| 50 |
-
outputs=gr.Video(label="Generated Video"),
|
| 51 |
-
title="Motion Control AI
|
| 52 |
-
description="
|
| 53 |
)
|
| 54 |
|
| 55 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
client = InferenceClient("akhaliq/animate-anyone")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
os.makedirs("outputs", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def animate(image, video):
|
| 10 |
|
| 11 |
output_path = "outputs/result.mp4"
|
| 12 |
|
| 13 |
+
result = client.text_to_video(
|
| 14 |
+
prompt="person moving naturally",
|
| 15 |
+
image=image,
|
| 16 |
+
video=video
|
| 17 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
with open(output_path, "wb") as f:
|
| 20 |
+
f.write(result)
|
| 21 |
|
| 22 |
return output_path
|
| 23 |
|
| 24 |
|
| 25 |
app = gr.Interface(
|
| 26 |
+
fn=animate,
|
| 27 |
inputs=[
|
| 28 |
gr.Image(type="filepath", label="Upload Image"),
|
| 29 |
+
gr.Video(label="Upload Motion Reference Video")
|
| 30 |
],
|
| 31 |
+
outputs=gr.Video(label="Generated Motion Video"),
|
| 32 |
+
title="Motion Control AI",
|
| 33 |
+
description="Animate image using motion reference video"
|
| 34 |
)
|
| 35 |
|
| 36 |
app.launch()
|