diff --git a/backend/db_repo.py b/backend/db_repo.py index 56b957ef..7fa9490c 100644 --- a/backend/db_repo.py +++ b/backend/db_repo.py @@ -848,13 +848,13 @@ def create_timing(self, **kwargs): attributes._data['canny_image_id'] = canny_image.id - if 'primay_image_id' in attributes.data: - if attributes.data['primay_image_id'] != None: - primay_image: InternalFileObject = InternalFileObject.objects.filter(uuid=attributes.data['primay_image_id'], is_disabled=False).first() + if 'primary_image_id' in attributes.data: + if attributes.data['primary_image_id'] != None: + primay_image: InternalFileObject = InternalFileObject.objects.filter(uuid=attributes.data['primary_image_id'], is_disabled=False).first() if not primay_image: return InternalResponse({}, 'invalid primary image uuid', False) - attributes._data['primay_image_id'] = primay_image.id + attributes._data['primary_image_id'] = primay_image.id timing = Timing.objects.create(**attributes.data) payload = { diff --git a/backend/serializers/dao.py b/backend/serializers/dao.py index 2231a725..61b606d6 100644 --- a/backend/serializers/dao.py +++ b/backend/serializers/dao.py @@ -80,7 +80,7 @@ class CreateTimingDao(serializers.Serializer): mask_id = serializers.CharField(max_length=100, required=False) canny_image_id = serializers.CharField(max_length=100, required=False) shot_id = serializers.CharField(max_length=100) - primary_image = serializers.CharField(max_length=100, required=False) + primary_image_id = serializers.CharField(max_length=100, required=False) alternative_images = serializers.CharField(max_length=100, required=False) notes = serializers.CharField(max_length=1024, required=False) aux_frame_index = serializers.IntegerField(required=False) diff --git a/ui_components/widgets/add_key_frame_element.py b/ui_components/widgets/add_key_frame_element.py index 54beed3d..f461efb2 100644 --- a/ui_components/widgets/add_key_frame_element.py +++ b/ui_components/widgets/add_key_frame_element.py @@ -1,8 +1,9 @@ import time from typing import Union import streamlit as st +from shared.constants import AnimationStyleType from ui_components.constants import CreativeProcessType, WorkflowStageType -from ui_components.models import InternalFileObject +from ui_components.models import InternalFileObject, InternalFrameTimingObject from ui_components.widgets.image_zoom_widgets import zoom_inputs from utils import st_memory @@ -11,7 +12,7 @@ from utils.constants import ImageStage from ui_components.methods.file_methods import generate_pil_image,save_or_host_file -from ui_components.methods.common_methods import apply_image_transformations, clone_styling_settings, create_frame_inside_shot, save_uploaded_image +from ui_components.methods.common_methods import add_image_variant, apply_image_transformations, clone_styling_settings, create_frame_inside_shot, save_new_image, save_uploaded_image from PIL import Image @@ -83,20 +84,30 @@ def add_key_frame(selected_image: Union[Image.Image, InternalFileObject], inheri len_shot_timing_list = len(timing_list) if len(timing_list) > 0 else 0 target_frame_position = len_shot_timing_list if target_frame_position is None else target_frame_position target_aux_frame_index = min(len(timing_list), target_frame_position) - _ = create_frame_inside_shot(shot_uuid, target_aux_frame_index) - timing_list = data_repo.get_timing_list_from_shot(shot_uuid) - # updating the newly created frame timing - - save_uploaded_image(selected_image, shot.project.uuid, timing_list[target_aux_frame_index].uuid, WorkflowStageType.SOURCE.value) - save_uploaded_image(selected_image, shot.project.uuid, timing_list[target_aux_frame_index].uuid, WorkflowStageType.STYLED.value) + if isinstance(selected_image, InternalFileObject): + saved_image = selected_image + else: + saved_image = save_new_image(selected_image, shot.project.uuid) + timing_data = { + "shot_id": shot_uuid, + "animation_style": AnimationStyleType.CREATIVE_INTERPOLATION.value, + "aux_frame_index": target_aux_frame_index, + "source_image_id": saved_image.uuid, + "primary_image_id": saved_image.uuid, + } + timing: InternalFrameTimingObject = data_repo.create_timing(**timing_data) + + add_image_variant(saved_image.uuid, timing.uuid) + + timing_list = data_repo.get_timing_list_from_shot(shot_uuid) if update_cur_frame_idx: # this part of code updates current_frame_index when a new keyframe is added if inherit_styling_settings == "Yes" and st.session_state['current_frame_index']: clone_styling_settings(st.session_state['current_frame_index'] - 1, timing_list[target_aux_frame_index-1].uuid) - if len(timing_list) == 1: + if len(timing_list) <= 1: st.session_state['current_frame_index'] = 1 st.session_state['current_frame_uuid'] = timing_list[0].uuid else: diff --git a/ui_components/widgets/shot_view.py b/ui_components/widgets/shot_view.py index a06c2d6d..a666353c 100644 --- a/ui_components/widgets/shot_view.py +++ b/ui_components/widgets/shot_view.py @@ -238,14 +238,11 @@ def shot_video_element(shot_uuid): with switch2: shot_animation_button(shot) - with st.expander("Details", expanded=False): - move_shot_buttons(shot, "side") - delete_shot_button(shot.uuid) - - create_video_download_button(shot.main_clip.location) + if shot.main_clip: + create_video_download_button(shot.main_clip.location)