Skip to content

Commit

Permalink
add to shot sped up
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushK52 committed Dec 22, 2023
1 parent 2c6935d commit be3fd8d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
8 changes: 4 additions & 4 deletions backend/db_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion backend/serializers/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 20 additions & 9 deletions ui_components/widgets/add_key_frame_element.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions ui_components/widgets/shot_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down

0 comments on commit be3fd8d

Please sign in to comment.