Joeythemonster/Text2Video-Zero
0
1import os2 3# App Canny utils4def edge_path_to_video_path(edge_path):5 video_path = edge_path6 7 vid_name = edge_path.split("/")[-1]8 if vid_name == "butterfly.mp4":9 video_path = "__assets__/canny_videos_mp4/butterfly.mp4"10 elif vid_name == "deer.mp4":11 video_path = "__assets__/canny_videos_mp4/deer.mp4"12 elif vid_name == "fox.mp4":13 video_path = "__assets__/canny_videos_mp4/fox.mp4"14 elif vid_name == "girl_dancing.mp4":15 video_path = "__assets__/canny_videos_mp4/girl_dancing.mp4"16 elif vid_name == "girl_turning.mp4":17 video_path = "__assets__/canny_videos_mp4/girl_turning.mp4"18 elif vid_name == "halloween.mp4":19 video_path = "__assets__/canny_videos_mp4/halloween.mp4"20 elif vid_name == "santa.mp4":21 video_path = "__assets__/canny_videos_mp4/santa.mp4"22 23 assert os.path.isfile(video_path)24 return video_path25 26 27# App Pose utils28def motion_to_video_path(motion):29 videos = [30 "__assets__/poses_skeleton_gifs/dance1_corr.mp4",31 "__assets__/poses_skeleton_gifs/dance2_corr.mp4",32 "__assets__/poses_skeleton_gifs/dance3_corr.mp4",33 "__assets__/poses_skeleton_gifs/dance4_corr.mp4",34 "__assets__/poses_skeleton_gifs/dance5_corr.mp4"35 ]36 if len(motion.split(" ")) > 1 and motion.split(" ")[1].isnumeric():37 id = int(motion.split(" ")[1]) - 138 return videos[id]39 else:40 return motion41 42 43# App Canny Dreambooth utils44def get_video_from_canny_selection(canny_selection):45 if canny_selection == "woman1":46 input_video_path = "__assets__/db_files_2fps/woman1.mp4"47 48 elif canny_selection == "woman2":49 input_video_path = "__assets__/db_files_2fps/woman2.mp4"50 51 elif canny_selection == "man1":52 input_video_path = "__assets__/db_files_2fps/man1.mp4"53 54 elif canny_selection == "woman3":55 input_video_path = "__assets__/db_files_2fps/woman3.mp4"56 else:57 input_video_path = canny_selection58 59 assert os.path.isfile(input_video_path)60 return input_video_path61 62 63def get_model_from_db_selection(db_selection):64 if db_selection == "Anime DB":65 input_video_path = 'PAIR/text2video-zero-controlnet-canny-anime'66 elif db_selection == "Avatar DB":67 input_video_path = 'PAIR/text2video-zero-controlnet-canny-avatar'68 elif db_selection == "GTA-5 DB":69 input_video_path = 'PAIR/text2video-zero-controlnet-canny-gta5'70 elif db_selection == "Arcane DB":71 input_video_path = 'PAIR/text2video-zero-controlnet-canny-arcane'72 else:73 input_video_path = db_selection74 75 return input_video_path76 77 78def get_db_name_from_id(id):79 db_names = ["Anime DB", "Arcane DB", "GTA-5 DB", "Avatar DB"]80 return db_names[id]81 82 83def get_canny_name_from_id(id):84 canny_names = ["woman1", "woman2", "man1", "woman3"]85 return canny_names[id]86 87 88def logo_name_to_path(name):89 logo_paths = {90 'Picsart AI Research': '__assets__/pair_watermark.png',91 'Text2Video-Zero': '__assets__/t2v-z_watermark.png',92 'None': None93 }94 if name in logo_paths:95 return logo_paths[name]96 return name97 98 99# App Depth utils100def depth_path_to_video_path(edge_path):101 video_path = edge_path102 103 vid_name = edge_path.split("/")[-1]104 if vid_name == "girl_dancing.mp4":105 video_path = "__assets__/depth_videos_mp4/girl_dancing.mp4"106 elif vid_name == "halloween.mp4":107 video_path = "__assets__/depth_videos_mp4/halloween.mp4"108 elif vid_name == "man.mp4":109 video_path = "__assets__/depth_videos_mp4/man.mp4"110 elif vid_name == "woman.mp4":111 video_path = "__assets__/depth_videos_mp4/woman.mp4"112 113 assert os.path.isfile(video_path)114 return video_path115 