import pandas as pd import gradio as gr df = pd.read_csv("liked_images.csv") df['url'] = df['url'].apply(lambda x: ' ') #' ') df['seed'] = df['seed'].apply(lambda x: str(x)) df['width'] = df['width'].apply(lambda x: str(x)) df['height'] = df['height'].apply(lambda x: str(x)) df['steps'] = df['steps'].apply(lambda x: str(x)) df['source'] = df['source'].apply(lambda x: str(x)) df = df[[ 'url', 'prompt', 'seed', 'width', 'height', 'steps', 'source']] def display_df(): df_images = df.head(10) return df_images def display_next10(dataframe, end): start = (end or dataframe.index[-1]) + 1 end = start + 9 df_images = df.loc[start:end] return df_images, end #Gradio Blocks with gr.Blocks() as demo: gr.Markdown("

Utility Gradio Space for viewing PlaygroundAI Images

") #gr.Markdown("""
""") gr.Markdown( """
This Tool helps you to analyze and inspect the images and corresponding prompts from Playground AI Images.
Suhail has recently shared an open dataset of all the liked images and their prompts from PlaygroundAI on Github here. This is an attempt to explore this dataset beautifully using the power and flexibility of Gradio!
To use the tool:First, click on the 'Initial' button, and then iteratively on the 'Next 10' button.
Bonus:Click on images to get the original PlaygroundAI image displayed on next tab
""") with gr.Row(): num_end = gr.Number(visible=False) b1 = gr.Button("Get Initial dataframe") b2 = gr.Button("Next 10 Rows") with gr.Row(): out_dataframe = gr.Dataframe(wrap=True, max_rows=10, overflow_row_behaviour= "paginate", datatype = ["markdown", "markdown", "str", "str", "str", "str", "str", "str"], interactive=False) b1.click(fn=display_df, outputs=out_dataframe, api_name="initial_dataframe") b2.click(fn=display_next10, inputs= [out_dataframe, num_end ], outputs=[out_dataframe, num_end], api_name="next_10_rows") gr.Markdown("
Please note that the Playground AI dataset shared on GitHub doesn't have images but links to those images. The idea is to get the maximum benefit out of this dataset and to find the best way to explore this dataset. Gradio enables us to embed markdowns within a dataframe, thus this app is able to display actual images instead of direct links(meh!). I hope you will have as much fun playing with this Space as I had building it.
") demo.launch(debug=True, show_error=True)