Spaces:
Sleeping
Sleeping
Delete video_gen.py
Browse files- video_gen.py +0 -37
video_gen.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import base64
|
| 3 |
-
from typing import List
|
| 4 |
-
import replicate
|
| 5 |
-
from dotenv import load_dotenv
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
load_dotenv()
|
| 9 |
-
replicate_client = replicate.Client(api_token= os.getenv("REPLICATE_API_KEY"))
|
| 10 |
-
|
| 11 |
-
def video_generation(
|
| 12 |
-
image_bytes,
|
| 13 |
-
prompt: str,
|
| 14 |
-
aspect_ratio: str,
|
| 15 |
-
resolution: str
|
| 16 |
-
):
|
| 17 |
-
encoded_image = base64.b64encode(image_bytes).decode("utf-8")
|
| 18 |
-
output = replicate_client.run(
|
| 19 |
-
"google/veo-3",
|
| 20 |
-
input={
|
| 21 |
-
"image": f"data:image/png;base64,{encoded_image}",
|
| 22 |
-
"prompt": prompt,
|
| 23 |
-
"resolution": resolution,
|
| 24 |
-
"aspect_ratio": aspect_ratio
|
| 25 |
-
}
|
| 26 |
-
)
|
| 27 |
-
urls: List[str] = []
|
| 28 |
-
if isinstance(output, list) and output:
|
| 29 |
-
first = output[0]
|
| 30 |
-
url = getattr(first, "url", str(first))
|
| 31 |
-
urls = [url]
|
| 32 |
-
elif isinstance(output, str):
|
| 33 |
-
urls = [output]
|
| 34 |
-
elif hasattr(output, "url"):
|
| 35 |
-
urls = [getattr(output, "url")]
|
| 36 |
-
if urls:
|
| 37 |
-
return urls[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|