Skip to content

Commit

Permalink
[DOCS]Update notebooks section (openvinotoolkit#26335)
Browse files Browse the repository at this point in the history
Updating notebook section with new content.
Porting: openvinotoolkit#26331

Co-authored-by: Maciej Smyk <[email protected]>
  • Loading branch information
sgolebiewski-intel and msmykx-intel authored Aug 30, 2024
1 parent 9515e26 commit fb27863
Show file tree
Hide file tree
Showing 230 changed files with 10,943 additions and 14,820 deletions.
2 changes: 1 addition & 1 deletion docs/nbdoc/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
repo_owner = "openvinotoolkit"
repo_name = "openvino_notebooks"
repo_branch = "tree/main"
artifacts_link = "http://repository.toolbox.iotg.sclab.intel.com/projects/ov-notebook/0.1.0-latest/20240806220807/dist/rst_files/"
artifacts_link = "http://repository.toolbox.iotg.sclab.intel.com/projects/ov-notebook/0.1.0-latest/20240827220813/dist/rst_files/"
blacklisted_extensions = ['.xml', '.bin']
notebooks_repo = "https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/"
notebooks_binder = "https://mybinder.org/v2/gh/openvinotoolkit/openvino_notebooks/HEAD?filepath="
Expand Down
217 changes: 105 additions & 112 deletions docs/notebooks/3D-pose-estimation-with-output.rst

Large diffs are not rendered by default.

65 changes: 29 additions & 36 deletions docs/notebooks/3D-segmentation-point-clouds-with-output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Guide <https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/README.
.. code:: ipython3
import platform
%pip install -q "openvino>=2023.1.0" "tqdm"
if platform.system() != "Windows":
%pip install -q "matplotlib>=3.4"
else:
Expand All @@ -73,16 +73,16 @@ Imports
import numpy as np
import matplotlib.pyplot as plt
import openvino as ov
# Fetch `notebook_utils` module
import requests
r = requests.get(
url="https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py",
)
open("notebook_utils.py", "w").write(r.text)
from notebook_utils import download_file
from notebook_utils import download_file, device_widget
Prepare the Model
-----------------
Expand Down Expand Up @@ -120,9 +120,9 @@ API, see this
.. code:: ipython3
ir_model_xml = onnx_model_path.with_suffix(".xml")
core = ov.Core()
if not ir_model_xml.exists():
# Convert model to OpenVINO Model
model = ov.convert_model(onnx_model_path)
Expand All @@ -142,37 +142,37 @@ Data Processing Module
def load_data(point_file: Union[str, Path]):
"""
Load the point cloud data and convert it to ndarray
Parameters:
point_file: string, path of .pts data
Returns:
point_set: point clound represented in np.array format
"""
point_set = np.loadtxt(point_file).astype(np.float32)
# normailization
point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0) # center
dist = np.max(np.sqrt(np.sum(point_set**2, axis=1)), 0)
point_set = point_set / dist # scale
return point_set
def visualize(point_set: np.ndarray):
"""
Create a 3D view for data visualization
Parameters:
point_set: np.ndarray, the coordinate data in X Y Z format
"""
fig = plt.figure(dpi=192, figsize=(4, 4))
ax = fig.add_subplot(111, projection="3d")
X = point_set[:, 0]
Y = point_set[:, 2]
Z = point_set[:, 1]
# Scale the view of each axis to adapt to the coordinate data distribution
max_range = np.array([X.max() - X.min(), Y.max() - Y.min(), Z.max() - Z.min()]).max() * 0.5
mid_x = (X.max() + X.min()) * 0.5
Expand All @@ -181,12 +181,12 @@ Data Processing Module
ax.set_xlim(mid_x - max_range, mid_x + max_range)
ax.set_ylim(mid_y - max_range, mid_y + max_range)
ax.set_zlim(mid_z - max_range, mid_z + max_range)
plt.tick_params(labelsize=5)
ax.set_xlabel("X", fontsize=10)
ax.set_ylabel("Y", fontsize=10)
ax.set_zlabel("Z", fontsize=10)
return ax
Visualize the original 3D data
Expand All @@ -206,7 +206,7 @@ chair for example.
"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/pts/chair.pts",
directory="data",
)
points = load_data(str(point_data))
X = points[:, 0]
Y = points[:, 2]
Expand All @@ -226,7 +226,7 @@ chair for example.
.. parsed-literal::
/tmp/ipykernel_3716970/2434168836.py:12: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
/tmp/ipykernel_56852/2434168836.py:12: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
ax.scatter3D(X, Y, Z, s=5, cmap="jet", marker="o", label="chair")
Expand All @@ -249,11 +249,11 @@ each input point.
# Parts of a chair
classes = ["back", "seat", "leg", "arm"]
# Preprocess the input data
point = points.transpose(1, 0)
point = np.expand_dims(point, axis=0)
# Print info about model input and output shape
print(f"input shape: {model.input(0).partial_shape}")
print(f"output shape: {model.output(0).partial_shape}")
Expand All @@ -274,15 +274,8 @@ select device from dropdown list for running inference using OpenVINO

.. code:: ipython3
import ipywidgets as widgets
device = widgets.Dropdown(
options=core.available_devices + ["AUTO"],
value="AUTO",
description="Device:",
disabled=False,
)
device = device_widget()
device
Expand All @@ -300,7 +293,7 @@ select device from dropdown list for running inference using OpenVINO
compiled_model = core.compile_model(model=model, device_name=device.value)
output_layer = compiled_model.output(0)
result = compiled_model([point])[output_layer]
# Find the label map for all points of chair with highest confidence
pred = np.argmax(result[0], axis=1)
ax = visualize(point)
Expand All @@ -316,18 +309,18 @@ select device from dropdown list for running inference using OpenVINO
XCur = np.array(XCur)
YCur = np.array(YCur)
ZCur = np.array(ZCur)
# add current point of the part
ax.scatter(XCur, YCur, ZCur, s=5, cmap="jet", marker="o", label=classes[i])
ax.set_title("3D Segmentation Visualization")
plt.legend(loc="upper right", fontsize=8)
plt.show()
.. parsed-literal::
/tmp/ipykernel_3716970/2804603389.py:23: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
/tmp/ipykernel_56852/2804603389.py:23: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
ax.scatter(XCur, YCur, ZCur, s=5, cmap="jet", marker="o", label=classes[i])
Expand Down
Loading

0 comments on commit fb27863

Please sign in to comment.