Skip to content

[Bug-fix][UI] Truncate long file names in the datasetviewer tab#408

Open
RihaanBH-1810 wants to merge 3 commits intoJdeRobot:masterfrom
RihaanBH-1810:bug-fix-ui-overlapping-image-names-in-dataset-viewer
Open

[Bug-fix][UI] Truncate long file names in the datasetviewer tab#408
RihaanBH-1810 wants to merge 3 commits intoJdeRobot:masterfrom
RihaanBH-1810:bug-fix-ui-overlapping-image-names-in-dataset-viewer

Conversation

@RihaanBH-1810
Copy link

@RihaanBH-1810 RihaanBH-1810 commented Mar 6, 2026

@dpascualhe
This PR fixes #407 by truncating the file names (while still retaining file extension) before passing them as captions to prevent overlapping.

Ps: I formatted the file with black hence the random change in adding parantheses.

Before fix :
Screenshot from 2026-03-06 23-02-00

After fix :
Screenshot from 2026-03-06 23-17-10

@dpascualhe
Copy link
Collaborator

Hi @RihaanBH-1810 , thanks for your contribution! Could you make the max. sample name size dependent on the image thumbnail size? In that way we can avoid using magic numbers. Thanks!

@RihaanBH-1810
Copy link
Author

Hi @dpascualhe , I think that would not be possible since we are using a streamlit component for image selector
I came across this code block in dataset_viewer.py


    # CSS for compact image grid
    st.markdown(
        """
        <style>
        .image-selector__image, .image-selector__image img {
            max-width: 120px; max-height: 40px; width:  40px; height: 40px; object-fit: contain;
        }
        </style>
    """,
        unsafe_allow_html=True,
    )

And tried assigning a variable for the width and then using that variable to change the maximum character length of the sample name.

But after playing around a bit and digging up online, I figured out that the style block is actually dead code.

Since the image_selector is a streamlit component, according to docs streamlit components are rendered in it's own iframe so the app's css and the components css are different. This component does not provide an option to change width manually either.

image

To sum it up since there is no variable based on which I can update the max sample name size dynamically. I think it is a better option to leave the max sample name size as a constant, since use_container_width = False in dataset_viewer.py

    # Image grid
    img_select_key = f"img_select_all_{dataset_path}_{split}_{current_page}"
    img_select_index = st.session_state.get(img_select_key)
    if img_select_index is None or not isinstance(img_select_index, int):
        img_select_index = 0
    selected_img_path = (
        image_select(
            label="",
            images=image_paths,
            captions=captions,
            use_container_width=False,
            key=img_select_key,
            index=img_select_index,
        )
        if image_paths
        else None
    )

The images in the grid would be of fixed size, around 10rem as defined in the component's css file so, upto 21 pixels max sample name should not be a problem for most of the normal screen sizes.

What are your thoughts on this ?

@RihaanBH-1810
Copy link
Author

also please ignore this commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] File names overlap in the dataset viewer tab when they are too long

2 participants