浏览代码

basic grid view controls

/pyrception-integration
leopoldo-zugasti 4 年前
当前提交
dd730077
共有 10 个文件被更改,包括 89 次插入19 次删除
  1. 68
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/preview.py
  2. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/goto.meta
  3. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/goto/build.meta
  4. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/pageselector.meta
  5. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/pageselector/build.meta
  6. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/slider.meta
  7. 0
      /com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/slider

68
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/preview.py


import streamlit.components.v1 as components
root_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(root_dir, "slider/build")
build_dir_slider = os.path.join(root_dir, "custom_components/slider/build")
build_dir_page_selector = os.path.join(root_dir, "custom_components/pageselector/build")
build_dir_go_to = os.path.join(root_dir, "custom_components/goto/build")
path=build_dir
path=build_dir_slider
)
_page_selector = components.declare_component(
"page_selector",
path=build_dir_page_selector
)
_go_to = components.declare_component(
"go_to",
path=build_dir_go_to
)

def page_selector(startAt, incrementAmt, key=0):
return _page_selector(startAt=startAt, incrementAmt=incrementAmt, key=key, default=0)
def go_to(key=0):
return _go_to(key=key, default=0)
#-------------------------------------END-------------------------------------------------------------------------------
def list_datasets(path) -> List:

"Please select a dataset...", list_datasets(base_dataset_dir)
)
num_cols = 3
if dataset_name is not None:
colors, dataset = load_perception_dataset(
os.path.join(base_dataset_dir, dataset_name)

# image, classes, labels, boxes, colors, "Bounding Boxes Preview", ""
#)
grid_view(num_cols, num_rows, colors, dataset)
grid_view(num_rows, colors, dataset)
def grid_view(num_cols, num_rows, colors, dataset):
print("Now did I create the slider?")
def grid_view(num_rows, colors, dataset):
header = st.beta_columns(3)
num_cols = header[2].slider(label="Image per row: ", min_value=1, max_value=5, step=1, value=3)
with header[1]:
start_at_2 = page_selector(0,num_cols * num_rows)
with header[0]:
start_at_2 = go_to()
inner_cols = st.beta_columns([0.1, 0.0001])
#inner_cols = st.beta_columns([0.1, 0.0001])
app_state = st.experimental_get_query_params()
if "start_at" in app_state:
start_at = int(app_state["start_at"][0])
else:
start_at = 0
#app_state = st.experimental_get_query_params()
#if "start_at" in app_state:
# start_at = int(app_state["start_at"][0])
#else:
# start_at = 0
if inner_cols[1].button('>'):
start_at = min(start_at + num_cols * num_rows, len(dataset)-(len(dataset) % (num_cols * num_rows)))
if inner_cols[0].button('<'):
start_at = max(0,start_at - num_cols * num_rows)
#if inner_cols[1].button('>'):
# overflow_image_count = len(dataset) % (num_cols * num_rows)
# overflow_image_count = (num_cols * num_rows) if overflow_image_count == 0 else overflow_image_count
# start_at = min(start_at + num_cols * num_rows, len(dataset)-overflow_image_count)
#if inner_cols[0].button('<'):
# start_at = max(0, start_at - num_cols * num_rows)
st.experimental_set_query_params(start_at=start_at)
#st.experimental_set_query_params(start_at=start_at)
for i in range(start_at, min(start_at + (num_cols * num_rows), len(dataset))):
for i in range(start_at_2, min(start_at_2 + (num_cols * num_rows), len(dataset))):
classes = dataset.classes
image, segmentation, target = dataset[i]
labels = target["labels"]

image = draw_image_with_boxes(
image, classes, labels, boxes, colors, "Bounding Boxes Preview", ""
)
cols[i % num_cols].image(image, caption=str(i), use_column_width = True)
cols[(i - (start_at_2 % num_cols)) % num_cols].image(image, caption=str(i), use_column_width = True)

8
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/goto.meta


fileFormatVersion: 2
guid: 90ea24385987ac342bb4ab6ced5479bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/goto/build.meta


fileFormatVersion: 2
guid: b7d30013d0642bc409e9481413b50d35
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/pageselector.meta


fileFormatVersion: 2
guid: 8c33b6eb24c7f7947968055a3abdb2f9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/pageselector/build.meta


fileFormatVersion: 2
guid: 7bf3cdf41e4977146929eaf3570bf360
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/slider.meta


fileFormatVersion: 2
guid: a044c6f798455524eaadba812477f558
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/slider → /com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components/slider

正在加载...
取消
保存