Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,28 +2,10 @@ import pandas as pd
|
|
| 2 |
import gradio as gr
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
-
|
| 6 |
-
#dataset = load_dataset("laion/laion-coco") # try smaller? evicted again. try try again
|
| 7 |
-
#dataset = load_dataset("laion/laion400m") # smaller still - you can do it!
|
| 8 |
-
dataset = load_dataset("laion/laion-art", split="train") # 1.2G? parquet
|
| 9 |
-
#dataset_filtered = dataset.filter(lambda x : x["TEXT"].contains
|
| 10 |
-
|
| 11 |
-
#dataset = dataset.filter(lambda example: example["TEXT"].startswith("Christmas"))
|
| 12 |
-
#len(sw)
|
| 13 |
-
#print(sw)
|
| 14 |
-
|
| 15 |
-
#print(dataset.features)
|
| 16 |
-
#print (type(dataset))
|
| 17 |
-
|
| 18 |
df = pd.DataFrame(dataset)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
df = df[["TEXT", "URL"]]
|
| 22 |
-
|
| 23 |
-
#try:
|
| 24 |
-
# df['URL'] = df['URL'].apply(lambda x: '<a href= "' + str(x) + '" target="_blank"> <img src= "' + str(x) + '"/> </a>')
|
| 25 |
-
#except:
|
| 26 |
-
# print("Exception adding URL anchor link template")
|
| 27 |
|
| 28 |
def display_df():
|
| 29 |
df_images = df.head(100)
|
|
@@ -38,7 +20,7 @@ def display_next100(dataframe, end):
|
|
| 38 |
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
gr.Markdown("<h1><center>🦁Lion Image Search🎨</center></h1>")
|
| 41 |
-
gr.Markdown("""<div align="center">Art Descriptions from <a href = "https://huggingface.co/datasets/laion/
|
| 42 |
|
| 43 |
with gr.Row():
|
| 44 |
num_end = gr.Number(visible=False)
|
|
@@ -46,7 +28,6 @@ with gr.Blocks() as demo:
|
|
| 46 |
b2 = gr.Button("Next 100 Images with Descriptions")
|
| 47 |
|
| 48 |
with gr.Row():
|
| 49 |
-
#out_dataframe = gr.Dataframe(wrap=True, max_rows=100, overflow_row_behaviour= "paginate", datatype = ["markdown", "markdown"], headers=['URL', 'TEXT'])
|
| 50 |
out_dataframe = gr.Dataframe(wrap=True, max_rows=100, overflow_row_behaviour= "paginate", headers=['TEXT','URL'])
|
| 51 |
|
| 52 |
b1.click(fn=display_df, outputs=out_dataframe)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
+
dataset = load_dataset("laion/laion-art", split="train") # 1.2G parquet of description and url to images representing art
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
df = pd.DataFrame(dataset)
|
| 7 |
+
df = df[["TEXT", "URL"]] # just text description and URL to image
|
| 8 |
+
df = df.sample(frac=1) # randomize order
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def display_df():
|
| 11 |
df_images = df.head(100)
|
|
|
|
| 20 |
|
| 21 |
with gr.Blocks() as demo:
|
| 22 |
gr.Markdown("<h1><center>🦁Lion Image Search🎨</center></h1>")
|
| 23 |
+
gr.Markdown("""<div align="center">Art Descriptions from <a href = "https://huggingface.co/datasets/laion/laion-art">Laion Art</a>. <a href="https://playgroundai.com/create">Create Art Here</a>. <a href="https://paperswithcode.com/datasets?q=image&v=lst&o=newest">Papers,Code,Datasets for Image AI Datasets</a>""")
|
| 24 |
|
| 25 |
with gr.Row():
|
| 26 |
num_end = gr.Number(visible=False)
|
|
|
|
| 28 |
b2 = gr.Button("Next 100 Images with Descriptions")
|
| 29 |
|
| 30 |
with gr.Row():
|
|
|
|
| 31 |
out_dataframe = gr.Dataframe(wrap=True, max_rows=100, overflow_row_behaviour= "paginate", headers=['TEXT','URL'])
|
| 32 |
|
| 33 |
b1.click(fn=display_df, outputs=out_dataframe)
|