import pandas as pd
import gradio as gr
df = pd.read_csv("images.csv")
df['url'] = df['url'].apply(lambda x: '
')
df = df[[ 'url', 'prompt']]
def display_df():
df_images = df.head(1000)
return df_images
def display_next1000(dataframe, end):
dataframe = dataframe.sample(frac=1)
start = (end or dataframe.index[-1]) + 1
end = start + 999
df_images = df.loc[start:end]
return df_images, end
with gr.Blocks() as demo:
gr.Markdown("
🍰PrompTart🎨
")
gr.Markdown("""Art Prompts from
Playground.
Git.
Create Art Here.
Papers,Code,Datasets for SOTA in Art""")
with gr.Row():
num_end = gr.Number(visible=False)
b1 = gr.Button("Images and Prompts 0-1000")
b2 = gr.Button("Next 1000 Images and Prompts")
with gr.Row():
out_dataframe = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate", datatype = ["markdown", "markdown"], headers=['url', 'prompt'])
b1.click(fn=display_df, outputs=out_dataframe)
b2.click(fn=display_next1000, inputs= [out_dataframe, num_end ], outputs=[out_dataframe, num_end])
demo.launch(debug=True, show_error=True)