Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import polars as pl
|
3 |
+
|
4 |
+
column_names = ["x", "y", "z", "l", "name", "data"]
|
5 |
+
|
6 |
+
with gr.Blocks() as demo:
|
7 |
+
labeled_points = gr.DataFrame(
|
8 |
+
value=None,
|
9 |
+
headers=column_names,
|
10 |
+
col_count=(len(column_names), "fixed"),
|
11 |
+
row_count=(1, "dynamic"),
|
12 |
+
type="polars",
|
13 |
+
interactive=True,
|
14 |
+
datatype=["number", "number", "number", "number", "str", "str"],
|
15 |
+
)
|
16 |
+
|
17 |
+
button = gr.Button("Submit")
|
18 |
+
|
19 |
+
def on_click(labeled_points):
|
20 |
+
point_info = [0, 0, 0, 0, "test", "test"]
|
21 |
+
new_row = pl.DataFrame([point_info], schema=labeled_points.schema, orient="row")
|
22 |
+
labeled_points = labeled_points.vstack(new_row)
|
23 |
+
return labeled_points
|
24 |
+
|
25 |
+
gr.on(button.click, on_click, labeled_points, labeled_points)
|
26 |
+
|
27 |
+
demo.launch(show_error=True)
|
28 |
+
|