Wiuhh commited on
Commit
c54e0e4
·
verified ·
1 Parent(s): 4403b46

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile.txt +21 -0
  2. env.example.txt +1 -0
  3. requirements.txt +3 -0
  4. ui.py +26 -0
  5. veo_vid.py +53 -0
Dockerfile.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.11
5
+
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
9
+
10
+ WORKDIR /app
11
+
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
+
15
+
16
+ COPY --chown=user ui.py ui.py
17
+ COPY --chown=user veo_vid.py veo_vid.py
18
+
19
+ EXPOSE 7860
20
+
21
+ CMD ["python", "ui.py"]
env.example.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY=
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ google-genai
2
+ gradio
3
+ python-dotenv
ui.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from veo_vid import generate_video
4
+
5
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
6
+ gr.Markdown("# Veo Video Generator\nEnter your prompt and generate a video!")
7
+ prompt = gr.Textbox(
8
+ label="Prompt",
9
+ value="A high-end fashion ad showing a confident male model in a new dark blue suit sprinting down a professional runway.",
10
+ )
11
+ generate_btn = gr.Button("Generate Video")
12
+ video_output = gr.Video(label="Generated Video")
13
+
14
+ def on_generate(prompt):
15
+ video_path = generate_video(prompt)
16
+ if video_path:
17
+ return gr.update(value=video_path)
18
+ else:
19
+ return gr.update(value=None)
20
+
21
+ generate_btn.click(on_generate, inputs=prompt, outputs=video_output)
22
+
23
+ if __name__ == "__main__":
24
+ demo.launch(
25
+ server_name="0.0.0.0", server_port=7860, auth=("devmode", "testdeployment8721")
26
+ )
veo_vid.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+
4
+ from dotenv import load_dotenv
5
+ from google import genai
6
+
7
+ load_dotenv()
8
+
9
+
10
+ def generate_video(prompt):
11
+ client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
12
+
13
+ operation = client.models.generate_videos(
14
+ model="veo-3.0-generate-001",
15
+ prompt=prompt,
16
+ config={
17
+ "aspect_ratio": "16:9",
18
+ "negative_prompt": "cartoon, drawing, low quality",
19
+ },
20
+ )
21
+
22
+ # Poll the operation status until the video is ready.
23
+ while not operation.done:
24
+ print("Waiting for video generation to complete...")
25
+ time.sleep(10)
26
+ operation = client.operations.get(operation)
27
+
28
+ # Download the generated video.
29
+ generated_video = operation.response.generated_videos[0]
30
+ client.files.download(file=generated_video.video)
31
+ generated_video.video.save("example.mp4")
32
+ print("Generated video saved to example.mp4")
33
+ return "example.mp4" # Return the path of the generated video
34
+
35
+
36
+ if __name__ == "__main__":
37
+
38
+ prompt = (
39
+ "A high-end fashion ad showing a confident male model in a new dark blue suit "
40
+ "sprinting down a professional runway. The model begins at the ramp's edge, "
41
+ "straightening his jacket and giving a close-up, focused look. He runs "
42
+ "forward, energetically engaging with the camera, then transitions to smooth "
43
+ "side and three-quarter views. The video uses fast, smooth cinematic cuts, "
44
+ "dynamic tracking, and stylish lateral pans. The model does a slow-motion "
45
+ "turn, strikes a confident pose with hands in pockets, and the camera "
46
+ "elegantly pans from shoes to face. Dramatic runway lighting, crisp highlights, "
47
+ "and an upbeat, trendy soundtrack add excitement. In the final second, the "
48
+ "model stops, looks directly into the camera with a smile, and the scene "
49
+ "blurs to a bold, minimalist animated brand title card: 'Best Name.' The "
50
+ "whole scene is energetic, clean, visually striking, and lasts 8 seconds, "
51
+ "echoing top luxury fashion campaigns."
52
+ )
53
+ generate_video(prompt)