harry900000 commited on
Commit
e6565e5
·
1 Parent(s): 09a9db5

add a script for inference using cli

Browse files
Files changed (1) hide show
  1. main.py +58 -0
main.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from argparse import ArgumentParser
2
+ import os
3
+ import sys
4
+
5
+
6
+ if __name__ == "__main__":
7
+ parser = ArgumentParser()
8
+ parser.add_argument("--skip-check-environment", action="store_true", help="Whether to skip environment checking")
9
+ parser.add_argument("--rgb", type=str, default=None, help="RGB video input")
10
+ parser.add_argument("--hdmap", type=str, required=True, help="HD Map video input")
11
+ parser.add_argument("--lidar", type=str, required=True, help="Lidar video input")
12
+ parser.add_argument(
13
+ "--prompt",
14
+ type=str,
15
+ default="The video is captured from a camera mounted on a car. The camera is facing forward. The video showcases a scenic golden-hour drive through a suburban area, bathed in the warm, golden hues of the setting sun. The dashboard camera captures the play of light and shadow as the sun’s rays filter through the trees, casting elongated patterns onto the road. The streetlights remain off, as the golden glow of the late afternoon sun provides ample illumination. The two-lane road appears to shimmer under the soft light, while the concrete barrier on the left side of the road reflects subtle warm tones. The stone wall on the right, adorned with lush greenery, stands out vibrantly under the golden light, with the palm trees swaying gently in the evening breeze. Several parked vehicles, including white sedans and vans, are seen on the left side of the road, their surfaces reflecting the amber hues of the sunset. The trees, now highlighted in a golden halo, cast intricate shadows onto the pavement. Further ahead, houses with red-tiled roofs glow warmly in the fading light, standing out against the sky, which transitions from deep orange to soft pastel blue. As the vehicle continues, a white sedan is seen driving in the same lane, while a black sedan and a white van move further ahead. The road markings are crisp, and the entire setting radiates a peaceful, almost cinematic beauty. The golden light, combined with the quiet suburban landscape, creates an atmosphere of tranquility and warmth, making for a mesmerizing and soothing drive.", # noqa: E501
16
+ help="prompt which the sampled video condition on",
17
+ )
18
+ parser.add_argument(
19
+ "--negative-prompt",
20
+ type=str,
21
+ default="The video captures a game playing, with bad crappy graphics and cartoonish frames. It represents a recording of old outdated games. The lighting looks very fake. The textures are very raw and basic. The geometries are very primitive. The images are very pixelated and of poor CG quality. There are many subtitles in the footage. Overall, the video is unrealistic at all.", # noqa: E501
22
+ help="negative prompt which the sampled video condition on",
23
+ )
24
+ parser.add_argument("--seed", type=int, default=1, help="Random seed")
25
+ parser.add_argument("--randomize-seed", action="store_true", help="Randomize seed")
26
+ parser.add_argument("--chunking-size", type=int, default=0, help="Chunking size (0 for no chunking)")
27
+ args = parser.parse_args()
28
+
29
+ # setup env
30
+ os.environ["CUDA_HOME"] = "/usr/local/cuda"
31
+ os.environ["LD_LIBRARY_PATH"] = "$CUDA_HOME/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH"
32
+ os.environ["PATH"] = "$CUDA_HOME/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:$PATH"
33
+
34
+ if not args.skip_check_environment:
35
+ from test_environment import main as check_environment
36
+
37
+ if not check_environment():
38
+ sys.exit(1)
39
+ else:
40
+ print("Skipping environment check")
41
+
42
+ from download_checkpoints import main as download_checkpoints
43
+ from helper import CHECKPOINTS_PATH, generate_video
44
+
45
+ # download checkpoints
46
+ os.makedirs(CHECKPOINTS_PATH, exist_ok=True)
47
+ download_checkpoints(hf_token="", output_dir=CHECKPOINTS_PATH, model="7b_av")
48
+
49
+ generate_video(
50
+ rgb_video_path=args.rgb,
51
+ hdmap_video_input=args.hdmap,
52
+ lidar_video_input=args.lidar,
53
+ prompt=args.prompt,
54
+ negative_prompt=args.negative_prompt,
55
+ seed=args.seed,
56
+ randomize_seed=args.randomize_seed,
57
+ chunking=args.chunking_size,
58
+ )