Spaces:
Runtime error
Runtime error
Commit
·
93f4017
1
Parent(s):
00072e0
fixes
Browse files
app.py
CHANGED
|
@@ -19,19 +19,14 @@ df = visit_bench.to_pandas()
|
|
| 19 |
print(f"Got {len(df)} items in dataframe")
|
| 20 |
df = df.sample(frac=1)
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# df['image'] = df['image_url'].apply(lambda x: '<a href= "' + str(x) + '" target="_blank"> <img src= "' + str(
|
| 25 |
-
# x) + '" width="400"/> </a>')
|
| 26 |
-
# df['image'] = df['image'].apply(lambda x: '<a href= "' + str(x) + '" target="_blank"> <img src= "' + str(
|
| 27 |
-
# x) + '" width="400"/> </a>')
|
| 28 |
-
df['image'] = df['image'].apply(lambda x: '<a href= "' + str(x['path']) + '" target="_blank"> <img src= "' + str(
|
| 29 |
-
x['path']) + '" width="400"/> </a>')
|
| 30 |
|
| 31 |
cols = list(df.columns)
|
| 32 |
cols.insert(0, cols.pop(cols.index('image')))
|
| 33 |
df = df.reindex(columns=cols)
|
| 34 |
LINES_NUMBER = 20
|
|
|
|
| 35 |
|
| 36 |
def display_df():
|
| 37 |
df_images = df.head(LINES_NUMBER)
|
|
@@ -54,6 +49,22 @@ initial_dataframe = display_df()
|
|
| 54 |
|
| 55 |
# Gradio Blocks
|
| 56 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
gr.Markdown("<h1><center>VisIT-Bench Dataset Viewer</center></h1>")
|
| 58 |
|
| 59 |
with gr.Row():
|
|
@@ -62,16 +73,14 @@ with gr.Blocks() as demo:
|
|
| 62 |
b2 = gr.Button("Next Rows")
|
| 63 |
|
| 64 |
with gr.Row():
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
b1.click(fn=display_df, outputs=out_dataframe, api_name="initial_dataframe")
|
| 77 |
b2.click(fn=display_next, inputs=[out_dataframe, num_end], outputs=[out_dataframe, num_end],
|
|
|
|
| 19 |
print(f"Got {len(df)} items in dataframe")
|
| 20 |
df = df.sample(frac=1)
|
| 21 |
|
| 22 |
+
df['image'] = df['image'].apply(lambda x: f'<a href="{x["path"]}" target="_blank"><img src="{x["path"]}" style="width:100%; max-width:800px; height:auto;"></a>')
|
| 23 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
cols = list(df.columns)
|
| 26 |
cols.insert(0, cols.pop(cols.index('image')))
|
| 27 |
df = df.reindex(columns=cols)
|
| 28 |
LINES_NUMBER = 20
|
| 29 |
+
df.drop(columns=['visual'],inplace=True)
|
| 30 |
|
| 31 |
def display_df():
|
| 32 |
df_images = df.head(LINES_NUMBER)
|
|
|
|
| 49 |
|
| 50 |
# Gradio Blocks
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
+
style = """
|
| 53 |
+
<style>
|
| 54 |
+
.gradio-container table tr td, .gradio-container table tr th {
|
| 55 |
+
padding: 10px 20px; /* Increase padding, adjust as needed */
|
| 56 |
+
white-space: normal; /* Ensure text wraps in both data cells and headers */
|
| 57 |
+
word-wrap: break-word; /* Break the word to prevent overflow */
|
| 58 |
+
vertical-align: top; /* Align text to the top of the cell */
|
| 59 |
+
}
|
| 60 |
+
.gradio-container table tr td:nth-child(1), .gradio-container table tr th:nth-child(1) {
|
| 61 |
+
white-space: nowrap; /* Prevent wrapping in image column and its header */
|
| 62 |
+
vertical-align: middle; /* Align images to the middle of the cell */
|
| 63 |
+
width: 600px; /* Set a specific width for the image column and its header */
|
| 64 |
+
}
|
| 65 |
+
</style>
|
| 66 |
+
"""
|
| 67 |
+
gr.HTML(style) # This line embeds your CSS in the interface
|
| 68 |
gr.Markdown("<h1><center>VisIT-Bench Dataset Viewer</center></h1>")
|
| 69 |
|
| 70 |
with gr.Row():
|
|
|
|
| 73 |
b2 = gr.Button("Next Rows")
|
| 74 |
|
| 75 |
with gr.Row():
|
| 76 |
+
out_dataframe = gr.Dataframe(
|
| 77 |
+
value=initial_dataframe,
|
| 78 |
+
row_count=LINES_NUMBER,
|
| 79 |
+
interactive=False,
|
| 80 |
+
datatype=["markdown", "str", "str", "bool", "bool", "bool", "str", "str", "str"],
|
| 81 |
+
# min_width=100,
|
| 82 |
+
column_widths=[300, 120, 120, 120, 120, 120, 120, 120, 120, 120]
|
| 83 |
+
)
|
|
|
|
|
|
|
| 84 |
|
| 85 |
b1.click(fn=display_df, outputs=out_dataframe, api_name="initial_dataframe")
|
| 86 |
b2.click(fn=display_next, inputs=[out_dataframe, num_end], outputs=[out_dataframe, num_end],
|