File size: 1,658 Bytes
dd31ccf ff3fa65 dd31ccf ff3fa65 dd31ccf ca82116 dd31ccf ca82116 b040c7e dd31ccf 2797e34 0be44e5 dd31ccf 0be44e5 dd31ccf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import base64
import json
from handler import EndpointHandler
from PIL import Image
import io
import os
import subprocess
# Initialize the handler
# base_dir = os.path.dirname(os.path.abspath(__file__))
# video_root = os.path.join(base_dir, "dw_poses_videos")
# extract_pose_path = os.path.join(base_dir, 'extract_dwpose_from_vid.py')
# command = f'python3 {extract_pose_path} --video_root {video_root}'
# # Run the command with shell=True
# result = subprocess.run(command, shell=True, capture_output=True, text=True)
# if result.returncode != 0:
# raise RuntimeError(f"Error running extract_dwpose_from_vid.py: {result.stderr}")
handler = EndpointHandler()
# Define sample inputs
inputs = {
"inputs": {
"ref_image_url": "https://media.discordapp.net/attachments/1237667074210267217/1247398713228263494/image.jpg?ex=665fe214&is=665e9094&hm=ba3863d8149e4e43c6ec271b09fcd4027b6a58cc65b7a658797ab9fbc74b4808&=&format=webp&width=896&height=1194",
"video_url": "https://firebasestorage.googleapis.com/v0/b/quiz-app-edffe.appspot.com/o/tell_my_bf_shortened_pose.mp4?alt=media&token=d3b7cb47-6fbb-435c-94a7-2cbd62705efb",
"length": 48,
"num_inference_steps": 15,
"cfg": 3.5,
"seed": -1,
"firebase_doc_id" : "0gkm91Ao0GsmQ2WdLP9c"
}
}
# Simulate an inference call
output = handler(inputs)
# # Decode the base64 video output
video_base64 = output.get("video", "")
video_bytes = base64.b64decode(video_base64)
# Save the video to a file
with open("output_video.mp4", "wb") as video_file:
video_file.write(video_bytes)
print("Inference completed. Output video saved as output_video.mp4")
|