Spaces:
No application file
No application file
Create app.py
Browse files
app.py
CHANGED
@@ -1,51 +1,22 @@
|
|
1 |
-
|
2 |
-
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
with open(output_file, "wb") as f:
|
11 |
-
f.write(result["video"])
|
12 |
-
return output_file
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
fn=generate_video,
|
17 |
-
inputs="text",
|
18 |
-
outputs="file",
|
19 |
-
title="AI Video Creator",
|
20 |
-
description="Generate videos using AI from text input."
|
21 |
-
)
|
22 |
-
iface.launch()
|
23 |
-
from fastapi import FastAPI, UploadFile
|
24 |
-
import ffmpeg
|
25 |
-
from transformers import pipeline
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
# Generate video from text
|
35 |
-
result = model(prompt)
|
36 |
-
output_file = "generated_video.mp4"
|
37 |
-
with open(output_file, "wb") as f:
|
38 |
-
f.write(result["video"])
|
39 |
-
|
40 |
-
return {"message": "Video generated successfully!", "file_path": output_file}
|
41 |
-
|
42 |
-
@app.post("/upload_video/")
|
43 |
-
async def upload_video(file: UploadFile):
|
44 |
-
input_file = f"uploaded_{file.filename}"
|
45 |
-
with open(input_file, "wb") as f:
|
46 |
-
f.write(file.file.read())
|
47 |
-
|
48 |
-
# Example: Trim video using FFmpeg
|
49 |
-
trimmed_file = "trimmed_video.mp4"
|
50 |
-
ffmpeg.input(input_file).output(trimmed_file, ss=0, t=10).run()
|
51 |
-
return {"message": "Video uploaded and trimmed!", "file_path": trimmed_file}
|
|
|
1 |
+
# Use a base image with GPU support
|
2 |
+
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
|
3 |
|
4 |
+
# Install Python and system dependencies
|
5 |
+
RUN apt-get update && apt-get install -y \
|
6 |
+
python3 python3-pip ffmpeg git curl
|
7 |
|
8 |
+
# Install Python dependencies
|
9 |
+
COPY requirements.txt /app/requirements.txt
|
10 |
+
RUN pip3 install --no-cache-dir -r /app/requirements.txt
|
|
|
|
|
|
|
11 |
|
12 |
+
# Copy application code
|
13 |
+
COPY . /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# Set the working directory
|
16 |
+
WORKDIR /app
|
17 |
|
18 |
+
# Expose app port
|
19 |
+
EXPOSE 8000
|
20 |
|
21 |
+
# Start the application
|
22 |
+
CMD ["python3", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|