File size: 1,314 Bytes
e18b068
 
 
0008388
ea26717
3cfa6d8
e18b068
 
 
 
 
bf5780c
e18b068
 
 
 
 
 
45a0743
61eb20b
e18b068
 
 
06f05df
 
e18b068
 
ebb33d6
e18b068
 
 
5753919
e18b068
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
import gradio as gr
 
df = pd.read_csv("images.csv")
df['url'] = df['url'].apply(lambda x: '<a href= "' + str(x) + '" target="_blank"> <img src= "' + str(x) + '"/> </a>') 
df = df[[ 'url', 'prompt']]

def display_df():
  df_images = df.head()
  return df_images

def display_next100(dataframe, end):
  start = (end  or dataframe.index[-1]) + 1
  end = start + 99
  df_images = df.loc[start:end]
  return df_images, end
  
with gr.Blocks() as demo:
  gr.Markdown("<h1><center>AIPromptSearch</center></h1>")
  gr.Markdown("""<div align="center">Images and Prompts from <a href = "https://playgroundai.com/">Playground AI</a>. <a href="https://github.com/playgroundai/liked_images">Github</a>.  <a href="https://playgroundai.com/create">Create Your Own Here</a>.""")

  with gr.Row():
    num_end = gr.Number(visible=False)
    b1 = gr.Button("Images and Prompts 0-100")
    b2 = gr.Button("Next 100 Images and Prompts")
    
  with gr.Row():
    out_dataframe = gr.Dataframe(wrap=True, max_rows=100, overflow_row_behaviour= "paginate", datatype = ["markdown", "markdown"], headers=['url', 'prompt'])
    
  b1.click(fn=display_df, outputs=out_dataframe) 
  b2.click(fn=display_next100, inputs= [out_dataframe, num_end ], outputs=[out_dataframe, num_end])

demo.launch(debug=True, show_error=True)