Spaces:
Runtime error
Runtime error
Hritik
commited on
Commit
·
534b4d3
1
Parent(s):
69fc7ba
first commit
Browse files- app.py +53 -0
- videocon_human.csv +0 -0
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from datasets import load_dataset
|
4 |
+
|
5 |
+
videocon_human = load_dataset('csv', data_files='videocon_human.csv')
|
6 |
+
print(videocon_human)
|
7 |
+
|
8 |
+
data_human = videocon_human['train']
|
9 |
+
print(data_human[0])
|
10 |
+
|
11 |
+
df = data_human.to_pandas()
|
12 |
+
cols = list(df.columns)
|
13 |
+
df = df.reindex(columns=cols)
|
14 |
+
|
15 |
+
LINES_NUMBER = 20
|
16 |
+
|
17 |
+
def display_df():
|
18 |
+
df_images = df.head(LINES_NUMBER)
|
19 |
+
return df_images
|
20 |
+
|
21 |
+
def display_next(dataframe, end):
|
22 |
+
start = int(end or len(dataframe))
|
23 |
+
end = int(start) + int(LINES_NUMBER)
|
24 |
+
global df
|
25 |
+
if end >= len(df) - 1:
|
26 |
+
start = 0
|
27 |
+
end = LINES_NUMBER
|
28 |
+
df = df.sample(frac=1)
|
29 |
+
print(f"Shuffle")
|
30 |
+
df_images = df.iloc[start:end]
|
31 |
+
assert len(df_images) == LINES_NUMBER
|
32 |
+
return df_images, end
|
33 |
+
|
34 |
+
initial_dataframe = display_df()
|
35 |
+
|
36 |
+
# Gradio Blocks
|
37 |
+
with gr.Blocks() as demo:
|
38 |
+
gr.Markdown("<h1><center>VideoCon-Human Dataset Viewer</center></h1>")
|
39 |
+
|
40 |
+
with gr.Row():
|
41 |
+
num_end = gr.Number(visible=False)
|
42 |
+
b1 = gr.Button("Get Initial dataframe")
|
43 |
+
b2 = gr.Button("Next Rows")
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
out_dataframe = gr.Dataframe(initial_dataframe, wrap=True, max_rows=LINES_NUMBER, overflow_row_behaviour="paginate",
|
47 |
+
interactive=False, datatype = ['str', 'str', 'str', 'str', 'str'])
|
48 |
+
|
49 |
+
b1.click(fn=display_df, outputs=out_dataframe, api_name="initial_dataframe")
|
50 |
+
b2.click(fn=display_next, inputs=[out_dataframe, num_end], outputs=[out_dataframe, num_end],
|
51 |
+
api_name="next_rows")
|
52 |
+
|
53 |
+
demo.launch(debug=True, show_error=True)
|
videocon_human.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|