Delje commited on
Commit
3cc3b07
·
verified ·
1 Parent(s): bb09213

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -45
app.py CHANGED
@@ -1,51 +1,22 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
 
4
- # Load model
5
- model = pipeline("text-to-video-generation", model="damo-vilab/modelscope-text-to-video-synthesis")
 
6
 
7
- def generate_video(prompt):
8
- result = model(prompt)
9
- output_file = "generated_video.mp4"
10
- with open(output_file, "wb") as f:
11
- f.write(result["video"])
12
- return output_file
13
 
14
- # Create Gradio interface
15
- iface = gr.Interface(
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
- app = FastAPI()
 
28
 
29
- # Load Hugging Face model (example: text-to-video)
30
- model = pipeline("text-to-video-generation", model="damo-vilab/modelscope-text-to-video-synthesis")
31
 
32
- @app.post("/generate_video/")
33
- async def generate_video(prompt: str):
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"]