Created
November 29, 2023 20:33
-
-
Save lucataco/54e16fd74aa589841710159a9930fffc to your computer and use it in GitHub Desktop.
Benchmark SVD speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import time | |
import json | |
import base64 | |
import requests | |
# Start SDXL locally: | |
# docker run -d -p 5000:5000 --gpus=all r8.im/stability-ai/stable-video-diffusion@sha256:3f0457e4619daac51203dedb472816fd4af51f3149fa7a9e0b5ffcf1b8172438 | |
url = "http://localhost:5000/predictions" | |
headers = { | |
"Content-Type": "application/json" | |
} | |
data = { | |
"input": { | |
"input_image": "https://replicate.delivery/pbxt/JvLi9smWKKDfQpylBYosqQRfPKZPntuAziesp0VuPjidq61n/rocket.png", | |
"decoding_t": 7, | |
} | |
} | |
t1 = time.time() | |
for _ in range(1): | |
response = requests.post(url, headers=headers, data=json.dumps(data)) | |
t2 = time.time() | |
# Save the response as a video | |
resp = response.json() | |
output = resp["output"] | |
# save as output.mp4 | |
with open("output.mp4", "wb") as f: | |
f.write(base64.b64decode(output.split(",")[1])) | |
# Print the time difference | |
print("Time taken: ", t2 - t1) | |
print("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment