浏览代码

Custom components and grid view

/pyrception-integration
leopoldo-zugasti 4 年前
当前提交
8a248dba
共有 8 个文件被更改,包括 123 次插入17 次删除
  1. 4
      com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs
  2. 1
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/__init__.py
  3. 108
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/preview.py
  4. 3
      com.unity.perception/package.json
  5. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/custom_components.meta
  6. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/slider.meta
  7. 8
      com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/slider/build.meta

4
com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs


}*/
string path = Application.dataPath.Replace("/Assets", "");
#if UNITY_EDITOR_WIN
string packagesPath = Application.dataPath.Replace("/Assets","/Library/PythonInstall/Scripts");
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
#endif
string pathToData = PlayerPrefs.GetString(SimulationState.latestOutputDirectoryKey);
#if UNITY_EDITOR_WIN
path = path.Replace("/", "\\");

1
com.unity.perception/Editor/Pyrception/pyrception-utils/pyrception_utils/__init__.py


"PyrceptionDatasetMetadata",
#"PyrceptionGCSDataset",
]

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


from PIL.ImageDraw import ImageDraw
from pyrception_utils import PyrceptionDataset
st.set_page_config(layout="wide")
#--------------------------------Custom component-----------------------------------------------------------------------
import streamlit.components.v1 as components
root_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(root_dir, "slider/build")
_discrete_slider = components.declare_component(
"discrete_slider",
path=build_dir
)
def discrete_slider(greeting, name, key,default=0):
return _discrete_slider(greeting=greeting, name=name, default=default, key=key)
#-------------------------------------END-------------------------------------------------------------------------------
def list_datasets(path) -> List:
"""

:param base_dataset_dir: The directory that contains the perceptions datasets.
:type str:
"""
st.markdown("# Synthetic Dataset Preview\n ## Unity Technologies ")
#st.markdown("# Synthetic Dataset Preview\n ## Unity Technologies ")
num_rows = 5
num_cols = 3
classes = dataset.classes
st.sidebar.selectbox(
"hello", classes
)
image_index = frame_selector_ui(dataset)
image, segmentation, target = dataset[image_index]
labels = target["labels"]
boxes = target["boxes"]
#classes = dataset.classes
#st.sidebar.selectbox(
# "hello", classes
#)
#image_index = frame_selector_ui(dataset)
#image, segmentation, target = dataset[image_index]
#labels = target["labels"]
#boxes = target["boxes"]
#st.image(image, use_column_width=True)

#draw_image_with_boxes(
# image, classes, labels, boxes, colors, "Bounding Boxes Preview", ""
#)
image = draw_image_with_semantic_segmentation(
image, dataset.metadata.image_size[0], dataset.metadata.image_size[1], segmentation, "Semantic Segmentation Preview", ""
)
image = draw_image_with_boxes(
image, classes, labels, boxes, colors, "Bounding Boxes Preview", ""
)
st.image(image, use_column_width=True)
#image = draw_image_with_semantic_segmentation(
# image, dataset.metadata.image_size[0], dataset.metadata.image_size[1], segmentation, "Semantic Segmentation Preview", ""
#)
#image = draw_image_with_boxes(
# image, classes, labels, boxes, colors, "Bounding Boxes Preview", ""
#)
grid_view(num_cols, num_rows, colors, dataset)
def sidebar():
return None
def navbar():
return None
def grid_view(num_cols, num_rows, colors, dataset):
print("Now did I create the slider?")
count_of_clicks = discrete_slider("Hello", "Leopoldo", "123")
st.write("Return value: ", count_of_clicks)
inner_cols = st.beta_columns([0.1, 0.0001])
cols = st.beta_columns(num_cols)
semantic_segmentation = st.sidebar.checkbox("Semantic Segmentation", key="ss")
bounding_boxes_2d = st.sidebar.checkbox("Bounding Boxes", key="bb2d")
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)
st.experimental_set_query_params(start_at=start_at)
for i in range(start_at, min(start_at + (num_cols * num_rows), len(dataset))):
classes = dataset.classes
image, segmentation, target = dataset[i]
labels = target["labels"]
boxes = target["boxes"]
if semantic_segmentation:
image = draw_image_with_semantic_segmentation(
image, dataset.metadata.image_size[0], dataset.metadata.image_size[1], segmentation, "Semantic Segmentation Preview", ""
)
if bounding_boxes_2d:
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)
def zoom(index):
return None
def preview_app(args):
"""

raise ValueError("Please specify the path to the main dataset directory!")
preview_app(args)

3
com.unity.perception/package.json


"com.unity.render-pipelines.core": "7.1.6",
"com.unity.simulation.capture": "0.0.10-preview.22",
"com.unity.simulation.client": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.22"
"com.unity.simulation.core": "0.0.10-preview.22",
"com.unity.scripting.python": "4.0.0-exp.5"
},
"description": "Tools for generating large-scale data sets for perception-based machine learning training and validation",
"displayName": "Perception",

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


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

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


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

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


fileFormatVersion: 2
guid: 7d2b91e9c75092d469fdd0af0acefd11
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存