File size: 1,996 Bytes
e18b068
 
 
0008388
ea26717
3cfa6d8
e18b068
 
95288f7
e18b068
 
a2fb452
 
 
 
 
95288f7
4b02e76
e18b068
95288f7
e18b068
 
d6065c2
a2fb452
 
 
 
 
 
d6065c2
e18b068
2dfb08b
d00b848
a2fb452
 
e18b068
 
 
95288f7
 
e18b068
a2fb452
 
 
 
e18b068
95288f7
e18b068
 
95288f7
a2fb452
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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(1000)
  return df_images

def display_df_search(search):
  df_images = df.loc[df['prompt'].str.contains(search, case=False, na=False)]
  #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

def Match(name):
    pd.set_option("display.max_rows", None)
    data = df
    swith=data.loc[data['prompt'].str.contains(name, case=False, na=False)]
    return swith
  
    
with gr.Blocks() as demo:
  gr.Markdown("<h1><center>🍰PrompTart🎨</center></h1>")
  gr.Markdown("""<div align="center">Art Prompts from <a href = "https://playgroundai.com/">Playground</a>. <a href="https://github.com/playgroundai/liked_images">Git</a>.  <a href="https://playgroundai.com/create">Create Art Here</a>.  <a href="https://paperswithcode.com/datasets?q=art&v=lst&o=newest">Papers,Code,Datasets for SOTA in Art</a>""")
  


  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(): # inputs and buttons
    inp = gr.Textbox(lines=1, default="", label="Search")
    b3 = gr.Button("Search")    
    
  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])
  b3.click(fn=display_df_search, inputs=inp, outputs=out_dataframe) 

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