Merge pull request #132 from nagolinc/main

add init_frame to txt2vid
pull/212/head
Alexey Borsky 2023-05-27 07:43:05 +03:00 committed by GitHub
commit ba3c17ef7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -114,6 +114,7 @@ def inputs_ui():
gr.HTML('Control video (each frame will be used as input image to CN): *NOT REQUIRED') gr.HTML('Control video (each frame will be used as input image to CN): *NOT REQUIRED')
with gr.Row(): with gr.Row():
t2v_file = gr.File(label="Input video", interactive=True, file_count="single", file_types=["video"], elem_id="tex_to_vid_chosen_file") t2v_file = gr.File(label="Input video", interactive=True, file_count="single", file_types=["video"], elem_id="tex_to_vid_chosen_file")
t2v_init_image = gr.Image(label="Input image", interactive=True, file_count="single", file_types=["image"], elem_id="tex_to_vid_init_image")
t2v_width, t2v_height, t2v_prompt, t2v_n_prompt, t2v_cfg_scale, t2v_seed, t2v_processing_strength, t2v_fix_frame_strength, t2v_sampler_index, t2v_steps = setup_common_values('txt2vid', t2v_args) t2v_width, t2v_height, t2v_prompt, t2v_n_prompt, t2v_cfg_scale, t2v_seed, t2v_processing_strength, t2v_fix_frame_strength, t2v_sampler_index, t2v_steps = setup_common_values('txt2vid', t2v_args)

View File

@ -86,12 +86,18 @@ def start_process(*args):
curr_video_frame = cv2.resize(curr_video_frame, (args_dict['width'], args_dict['height'])) curr_video_frame = cv2.resize(curr_video_frame, (args_dict['width'], args_dict['height']))
utils.set_CNs_input_image(args_dict, Image.fromarray(curr_video_frame)) utils.set_CNs_input_image(args_dict, Image.fromarray(curr_video_frame))
processed_frames, _, _, _ = utils.txt2img(args_dict) if args_dict['init_image'] is not None:
processed_frame = np.array(processed_frames[0])[...,:3] #resize array to args_dict['width'], args_dict['height']
#if input_video is not None: image_array=args_dict['init_image']#this is a numpy array
# processed_frame = skimage.exposure.match_histograms(processed_frame, curr_video_frame, channel_axis=-1) init_frame = np.array(Image.fromarray(image_array).resize((args_dict['width'], args_dict['height'])).convert('RGB'))
processed_frame = np.clip(processed_frame, 0, 255).astype(np.uint8) processed_frame = init_frame.copy()
init_frame = processed_frame.copy() else:
processed_frames, _, _, _ = utils.txt2img(args_dict)
processed_frame = np.array(processed_frames[0])[...,:3]
#if input_video is not None:
# processed_frame = skimage.exposure.match_histograms(processed_frame, curr_video_frame, channel_axis=-1)
processed_frame = np.clip(processed_frame, 0, 255).astype(np.uint8)
init_frame = processed_frame.copy()
output_video = cv2.VideoWriter(output_video_name, cv2.VideoWriter_fourcc(*'mp4v'), args_dict['fps'], (args_dict['width'], args_dict['height'])) output_video = cv2.VideoWriter(output_video_name, cv2.VideoWriter_fourcc(*'mp4v'), args_dict['fps'], (args_dict['width'], args_dict['height']))
output_video.write(cv2.cvtColor(processed_frame, cv2.COLOR_RGB2BGR)) output_video.write(cv2.cvtColor(processed_frame, cv2.COLOR_RGB2BGR))

View File

@ -10,7 +10,7 @@ def get_component_names():
'v2v_sampler_index', 'v2v_steps', 'v2v_override_settings', 'v2v_sampler_index', 'v2v_steps', 'v2v_override_settings',
'v2v_occlusion_mask_blur', 'v2v_occlusion_mask_trailing', 'v2v_occlusion_mask_flow_multiplier', 'v2v_occlusion_mask_difo_multiplier', 'v2v_occlusion_mask_difs_multiplier', 'v2v_occlusion_mask_blur', 'v2v_occlusion_mask_trailing', 'v2v_occlusion_mask_flow_multiplier', 'v2v_occlusion_mask_difo_multiplier', 'v2v_occlusion_mask_difs_multiplier',
'v2v_step_1_processing_mode', 'v2v_step_1_blend_alpha', 'v2v_step_1_seed', 'v2v_step_2_seed', 'v2v_step_1_processing_mode', 'v2v_step_1_blend_alpha', 'v2v_step_1_seed', 'v2v_step_2_seed',
't2v_file', 't2v_width', 't2v_height', 't2v_prompt', 't2v_n_prompt', 't2v_cfg_scale', 't2v_seed', 't2v_processing_strength', 't2v_fix_frame_strength', 't2v_file','t2v_init_image', 't2v_width', 't2v_height', 't2v_prompt', 't2v_n_prompt', 't2v_cfg_scale', 't2v_seed', 't2v_processing_strength', 't2v_fix_frame_strength',
't2v_sampler_index', 't2v_steps', 't2v_length', 't2v_fps', 't2v_sampler_index', 't2v_steps', 't2v_length', 't2v_fps',
'glo_save_frames_check' 'glo_save_frames_check'
] ]