Skip to content

Commit

Permalink
Merge pull request #60 from banodoco/green-head
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
piyushK52 authored Dec 22, 2023
2 parents c74a521 + c32d45a commit 4919ca0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
23 changes: 12 additions & 11 deletions ui_components/widgets/explorer_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,15 @@ def gallery_image_view(project_uuid,page_number=1,num_items_per_page=20, open_de
if project_settings.total_shortlist_gallery_pages != res_payload['total_pages']:
project_settings.total_shortlist_gallery_pages = res_payload['total_pages']
st.rerun()
def is_image_truncated(image_path):
try:
img = Image.open(image_path)
img.verify() # verify that it is, in fact an image
except (IOError, SyntaxError) as e:
return True
return False

# def is_image_truncated(image_path):
# try:
# img = Image.open(image_path)
# img.verify() # verify that it is, in fact an image
# except (IOError, SyntaxError) as e:
# return True
# return False

total_image_count = res_payload['count']
if gallery_image_list and len(gallery_image_list):
start_index = 0
Expand All @@ -314,10 +316,9 @@ def is_image_truncated(image_path):
for j in range(num_columns):
if i + j < len(gallery_image_list):
with cols[j]:
if not is_image_truncated(gallery_image_list[i + j].location):
st.image(gallery_image_list[i + j].location, use_column_width=True)
else:
st.error("The image is truncated and cannot be displayed.")
st.image(gallery_image_list[i + j].location, use_column_width=True)
# else:
# st.error("The image is truncated and cannot be displayed.")
if view in ["explorer", "shortlist"]:
if shortlist:
if st.button("Remove from shortlist ➖", key=f"shortlist_{gallery_image_list[i + j].uuid}",use_container_width=True, help="Remove from shortlist"):
Expand Down
8 changes: 4 additions & 4 deletions ui_components/widgets/shot_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ def shot_video_element(shot_uuid):
move_shot_buttons(shot, "side")
delete_shot_button(shot.uuid)
if shot.main_clip:
create_video_download_button(shot.main_clip.location)
create_video_download_button(shot.main_clip.location, tag="main_clip")



def create_video_download_button(video_location):
def create_video_download_button(video_location, tag="temp"):
# Extract the file name from the video location
file_name = os.path.basename(video_location)

Expand All @@ -257,7 +257,7 @@ def create_video_download_button(video_location):
data=response.content,
file_name=file_name,
mime='video/mp4',
key=file_name,
key=tag + str(file_name),
use_container_width=True
)
else: # local file
Expand All @@ -267,7 +267,7 @@ def create_video_download_button(video_location):
data=file,
file_name=file_name,
mime='video/mp4',
key=file_name,
key=tag + str(file_name),
use_container_width=True
)
def shot_adjustment_button(shot):
Expand Down
15 changes: 7 additions & 8 deletions ui_components/widgets/variant_comparison_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def variant_comparison_grid(ele_uuid, stage=CreativeProcessType.MOTION.value):
else:
st.image(variants[current_variant].location, use_column_width=True)
with st.expander(f"Variant #{current_variant + 1} details"):
create_video_download_button(variants[current_variant].location)
variant_inference_detail_element(variants[current_variant], stage, shot_uuid, timing_list)
create_video_download_button(variants[current_variant].location, tag="var_compare")
variant_inference_detail_element(variants[current_variant], stage, shot_uuid, timing_list, tag="var_compare")

# Determine the start and end indices for additional variants on the current page
additional_variants = [idx for idx in range(len(variants) - 1, -1, -1) if idx != current_variant]
Expand Down Expand Up @@ -97,9 +97,8 @@ def variant_comparison_grid(ele_uuid, stage=CreativeProcessType.MOTION.value):
else:
st.image(variants[variant_index].location, use_column_width=True) if variants[variant_index] else st.error("No image present")
with st.expander(f"Variant #{variant_index + 1} details"):
create_video_download_button(variants[variant_index].location)

variant_inference_detail_element(variants[variant_index], stage, shot_uuid, timing_list)
create_video_download_button(variants[variant_index].location, tag="var_details")
variant_inference_detail_element(variants[variant_index], stage, shot_uuid, timing_list, tag="var_details")

next_col += 1
if next_col >= num_columns or i == len(page_indices) - 1 or len(page_indices) == i:
Expand All @@ -109,7 +108,7 @@ def variant_comparison_grid(ele_uuid, stage=CreativeProcessType.MOTION.value):
# Add markdown line if this is not the last variant in page_indices


def variant_inference_detail_element(variant, stage, shot_uuid, timing_list=""):
def variant_inference_detail_element(variant, stage, shot_uuid, timing_list="", tag="temp"):
data_repo = DataRepo()
shot = data_repo.get_shot_from_uuid(shot_uuid)

Expand All @@ -131,7 +130,7 @@ def variant_inference_detail_element(variant, stage, shot_uuid, timing_list=""):
add_variant_to_shot_element(variant, shot.project.uuid)

if stage == CreativeProcessType.MOTION.value:
if st.button("Load up settings from this variant", key=f"{variant.name}", help="This will enter the settings from this variant into the inputs below - you can also use them on other shots", use_container_width=True):
if st.button("Load up settings from this variant", key=f"{tag}_{variant.name}", help="This will enter the settings from this variant into the inputs below - you can also use them on other shots", use_container_width=True):
print("Loading settings")
print(len(timing_list))
new_data = prepare_values(fetch_inference_data(variant), timing_list)
Expand All @@ -140,7 +139,7 @@ def variant_inference_detail_element(variant, stage, shot_uuid, timing_list=""):
st.success("Settings loaded - scroll down to run them.")
time.sleep(0.3)
st.rerun()
if st.button("Sync audio/duration", key=f"{variant.uuid}", help="Updates video length and the attached audio", use_container_width=True):
if st.button("Sync audio/duration", key=f"{tag}_{variant.uuid}", help="Updates video length and the attached audio", use_container_width=True):
data_repo = DataRepo()
_ = sync_audio_and_duration(variant, shot_uuid)
_ = data_repo.get_shot_list(shot.project.uuid, invalidate_cache=True)
Expand Down

0 comments on commit 4919ca0

Please sign in to comment.