-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputs.py
58 lines (52 loc) · 1.41 KB
/
outputs.py
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
54
55
56
57
58
import pandas as pd
import numpy as np
import streamlit as st
def show_ann_count():
json_out = st.session_state.json_out
n_anns = [len(json["objects"]) for json in json_out]
data = pd.DataFrame(
{
"n_bbox": [n_anns],
}
)
st.dataframe(
data,
column_config={
"n_bbox": st.column_config.LineChartColumn(
"Number of Bounding Boxes",
y_min=0,
y_max=10,
)
},
hide_index=True,
use_container_width=True,
)
def show_output_df():
st.subheader("Output Dataframe")
result = make_dataframe()
st.dataframe(
result,
use_container_width=True,
)
def make_dataframe():
result = None
for json_out in st.session_state.json_out:
for obj in json_out["objects"]:
data_tmp = pd.DataFrame(
{
"filename": json_out["filename"],
"x": obj["left"],
"y": obj["top"],
"w": obj["width"],
"h": obj["height"],
"red": obj["red"],
"green": obj["green"],
"blue": obj["blue"],
},
index=[0],
)
result = pd.concat(
[result, data_tmp],
ignore_index=True,
)
return result