Spaces:
Runtime error
Runtime error
Jamiiwej2903
commited on
Commit
•
ee258e0
1
Parent(s):
a3b8faa
Update main.py
Browse files
main.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI, File, UploadFile
|
2 |
-
from pydantic import BaseModel
|
3 |
from huggingface_hub import InferenceClient
|
4 |
import uvicorn
|
5 |
from fastapi.responses import StreamingResponse
|
@@ -10,15 +9,15 @@ app = FastAPI()
|
|
10 |
|
11 |
client = InferenceClient("stabilityai/stable-video-diffusion-img2vid-xt-1-1-tensorrt")
|
12 |
|
13 |
-
class Item(BaseModel):
|
14 |
-
fps: int = 7
|
15 |
-
num_frames: int = 14
|
16 |
-
motion_bucket_id: int = 127
|
17 |
-
cond_aug: float = 0.02
|
18 |
-
seed: int = 0
|
19 |
-
|
20 |
@app.post("/generate_video/")
|
21 |
-
async def generate_video_api(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Read the uploaded image file
|
23 |
image_content = await file.read()
|
24 |
|
@@ -28,11 +27,11 @@ async def generate_video_api(item: Item, file: UploadFile = File(...)):
|
|
28 |
# Generate the video
|
29 |
video = client.image_to_video(
|
30 |
image=image_base64,
|
31 |
-
fps=
|
32 |
-
num_frames=
|
33 |
-
motion_bucket_id=
|
34 |
-
cond_aug=
|
35 |
-
seed=
|
36 |
)
|
37 |
|
38 |
# Return the video as a streaming response
|
|
|
1 |
+
from fastapi import FastAPI, File, UploadFile, Form
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import uvicorn
|
4 |
from fastapi.responses import StreamingResponse
|
|
|
9 |
|
10 |
client = InferenceClient("stabilityai/stable-video-diffusion-img2vid-xt-1-1-tensorrt")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
@app.post("/generate_video/")
|
13 |
+
async def generate_video_api(
|
14 |
+
file: UploadFile = File(...),
|
15 |
+
fps: int = Form(7),
|
16 |
+
num_frames: int = Form(14),
|
17 |
+
motion_bucket_id: int = Form(127),
|
18 |
+
cond_aug: float = Form(0.02),
|
19 |
+
seed: int = Form(0)
|
20 |
+
):
|
21 |
# Read the uploaded image file
|
22 |
image_content = await file.read()
|
23 |
|
|
|
27 |
# Generate the video
|
28 |
video = client.image_to_video(
|
29 |
image=image_base64,
|
30 |
+
fps=fps,
|
31 |
+
num_frames=num_frames,
|
32 |
+
motion_bucket_id=motion_bucket_id,
|
33 |
+
cond_aug=cond_aug,
|
34 |
+
seed=seed
|
35 |
)
|
36 |
|
37 |
# Return the video as a streaming response
|