Skip to content

Commit

Permalink
[DOCS] Updating Interactive Tutorials for 2025 version -porting (#28821)
Browse files Browse the repository at this point in the history
port: #28820

Co-authored-by: sgolebiewski-intel <[email protected]>
  • Loading branch information
kblaszczak-intel and sgolebiewski-intel authored Feb 4, 2025
1 parent 63acac4 commit 842a81d
Show file tree
Hide file tree
Showing 348 changed files with 16,532 additions and 15,819 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/20241209220902/dist/rst_files/"
artifacts_link = "http://repository.toolbox.iotg.sclab.intel.com/projects/ov-notebook/0.1.0-latest/20250203220806/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
74 changes: 40 additions & 34 deletions docs/notebooks/3D-pose-estimation-with-output.rst

Large diffs are not rendered by default.

89 changes: 50 additions & 39 deletions docs/notebooks/3D-segmentation-point-clouds-with-output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,22 @@ 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)
if not Path("notebook_utils.py").exists():
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, device_widget
# Read more about telemetry collection at https://github.com/openvinotoolkit/openvino_notebooks?tab=readme-ov-file#-telemetry
from notebook_utils import collect_telemetry
collect_telemetry("3D-segmentation-point-clouds.ipynb")
Prepare the Model
-----------------
Expand All @@ -92,12 +98,14 @@ find more point clouds examples
# Set the data and model directories, model source URL and model filename
MODEL_DIR = Path("model")
MODEL_DIR.mkdir(exist_ok=True)
download_file(
"https://storage.googleapis.com/ailia-models/pointnet_pytorch/chair_100.onnx",
directory=Path(MODEL_DIR),
show_progress=False,
)
onnx_model_path = MODEL_DIR / "chair_100.onnx"
if not onnx_model_path.exists():
download_file(
"https://storage.googleapis.com/ailia-models/pointnet_pytorch/chair_100.onnx",
directory=Path(MODEL_DIR),
show_progress=False,
)
Convert the ONNX model to OpenVINO IR. An OpenVINO IR (Intermediate
Representation) model consists of an ``.xml`` file, containing
Expand All @@ -108,14 +116,14 @@ function returns an OpenVINO model ready to load on a device and start
making predictions. We can save it on a disk for next usage with
``ov.save_model``. For more information about model conversion Python
API, see this
`page <https://docs.openvino.ai/2025/openvino-workflow/model-preparation.html>`__.
`page <https://docs.openvino.ai/2024/openvino-workflow/model-preparation.html>`__.

.. 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 @@ -135,37 +143,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 @@ -174,12 +182,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 @@ -195,11 +203,14 @@ chair for example.
.. code:: ipython3
# Download data from the openvino_notebooks storage
point_data = download_file(
"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/pts/chair.pts",
directory="data",
)
point_data_path = Path("data") / "chair.pts"
if not point_data_path.exists():
point_data = download_file(
"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 @@ -219,7 +230,7 @@ chair for example.
.. parsed-literal::
/tmp/ipykernel_2157242/2434168836.py:12: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
/tmp/ipykernel_3273469/2331834230.py:15: 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 @@ -242,11 +253,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 @@ -268,7 +279,7 @@ select device from dropdown list for running inference using OpenVINO
.. code:: ipython3
device = device_widget()
device
Expand All @@ -286,7 +297,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 @@ -302,18 +313,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_2157242/2804603389.py:23: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
/tmp/ipykernel_3273469/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

This file was deleted.

39 changes: 28 additions & 11 deletions docs/notebooks/action-recognition-webcam-with-output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ Imports
# 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)
if not Path("notebook_utils.py").exists():
r = requests.get(
url="https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py",
)
open("notebook_utils.py", "w").write(r.text)
import notebook_utils as utils
# Read more about telemetry collection at https://github.com/openvinotoolkit/openvino_notebooks?tab=readme-ov-file#-telemetry
from notebook_utils import collect_telemetry
collect_telemetry("action-recognition-webcam.ipynb")
The models
----------
Expand Down Expand Up @@ -178,10 +184,12 @@ also provides the text file embedded into this notebook.
.. code:: ipython3
# Download the text from the openvino_notebooks storage
vocab_file_path = utils.download_file(
"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/text/kinetics.txt",
directory="data",
)
if not (Path("data") / "kinetics.txt").exists():
vocab_file_path = utils.download_file(
"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/text/kinetics.txt",
directory="data",
)
with vocab_file_path.open(mode="r") as f:
labels = [line.strip() for line in f]
Expand Down Expand Up @@ -676,18 +684,27 @@ multi-camera systems).
USE_WEBCAM = False
cam_id = 0
video_file = "https://archive.org/serve/ISSVideoResourceLifeOnStation720p/ISS%20Video%20Resource_LifeOnStation_720p.mp4"
video_url = "https://archive.org/serve/ISSVideoResourceLifeOnStation720p/ISS%20Video%20Resource_LifeOnStation_720p.mp4"
video_file = Path("ISS%20Video%20Resource_LifeOnStation_720p.mp4")
if not USE_WEBCAM and video_file.exists():
utils.download_file(video_url, filename=video_file.name)
source = cam_id if USE_WEBCAM else video_file
additional_options = {"skip_first_frames": 600, "flip": False} if not USE_WEBCAM else {"flip": True}
run_action_recognition(source=source, use_popup=False, **additional_options)
.. parsed-literal::
.. image:: action-recognition-webcam-with-output_files/action-recognition-webcam-with-output_22_0.png
Cannot open ISS%20Video%20Resource_LifeOnStation_720p.mp4
.. parsed-literal::
Source ended
[ WARN:[email protected]] global cap.cpp:175 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.11.0) /io/opencv/modules/videoio/src/cap_images.cpp:237: error: (-5:Bad argument) CAP_IMAGES: error, expected '0?[1-9][du]' pattern, got: ISS%20Video%20Resource_LifeOnStation_720p.mp4 in function 'icvExtractPattern'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion docs/notebooks/all_notebooks_paths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ notebooks/clip-language-saliency-map/clip-language-saliency-map.ipynb
notebooks/clip-zero-shot-image-classification/clip-zero-shot-classification.ipynb
notebooks/controlnet-stable-diffusion/controlnet-stable-diffusion.ipynb
notebooks/convert-to-openvino/convert-to-openvino.ipynb
notebooks/cross-lingual-books-alignment/cross-lingual-books-alignment.ipynb
notebooks/ct-segmentation-quantize/ct-segmentation-quantize-nncf.ipynb
notebooks/ddcolor-image-colorization/ddcolor-image-colorization.ipynb
notebooks/deepseek-r1/deepseek-r1.ipynb
notebooks/depth-anything/depth-anything.ipynb
notebooks/depth-anything/depth-anything-v2.ipynb
notebooks/detectron2-to-openvino/detectron2-to-openvino.ipynb
Expand Down Expand Up @@ -42,6 +42,8 @@ notebooks/hello-world/hello-world.ipynb
notebooks/hugging-face-hub/hugging-face-hub.ipynb
notebooks/hunyuan-dit-image-generation/hunyuan-dit-image-generation.ipynb
notebooks/image-classification-quantization/image-classification-quantization.ipynb
notebooks/image-to-image-genai/image-to-image-genai.ipynb
notebooks/inpainting-genai/inpainting-genai.ipynb
notebooks/instant-id/instant-id.ipynb
notebooks/instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb
notebooks/internvl2/internvl2.ipynb
Expand All @@ -63,9 +65,11 @@ notebooks/llm-agent-react/llm-agent-react-langchain.ipynb
notebooks/llm-chatbot/llm-chatbot-generate-api.ipynb
notebooks/llm-chatbot/llm-chatbot.ipynb
notebooks/llm-question-answering/llm-question-answering.ipynb
notebooks/llm-rag-langchain/llm-rag-langchain-genai.ipynb
notebooks/llm-rag-langchain/llm-rag-langchain.ipynb
notebooks/llm-rag-llamaindex/llm-rag-llamaindex.ipynb
notebooks/localai/localai.ipynb
notebooks/ltx-video/ltx-video.ipynb
notebooks/magika-content-type-recognition/magika-content-type-recognition.ipynb
notebooks/meter-reader/meter-reader.ipynb
notebooks/minicpm-v-multimodal-chatbot/minicpm-v-multimodal-chatbot.ipynb
Expand All @@ -75,11 +79,13 @@ notebooks/mobileclip-video-search/mobileclip-video-search.ipynb
notebooks/modelscope-to-openvino/modelscope-to-openvino.ipynb
notebooks/model-server/model-server.ipynb
notebooks/multilora-image-generation/multilora-image-generation.ipynb
notebooks/multimodal-rag/multimodal-rag-llamaindex.ipynb
notebooks/music-generation/music-generation.ipynb
notebooks/named-entity-recognition/named-entity-recognition.ipynb
notebooks/nano-llava-multimodal-chatbot/nano-llava-multimodal-chatbot.ipynb
notebooks/nuextract-structure-extraction/nuextract-structure-extraction.ipynb
notebooks/object-detection-webcam/object-detection.ipynb
notebooks/omnigen/omnigen.ipynb
notebooks/omniparser/omniparser.ipynb
notebooks/oneformer-segmentation/oneformer-segmentation.ipynb
notebooks/openvino-api/openvino-api.ipynb
Expand Down Expand Up @@ -114,6 +120,7 @@ notebooks/rmbg-background-removal/rmbg-background-removal.ipynb
notebooks/s3d-mil-nce-text-to-video-retrieval/s3d-mil-nce-text-to-video-retrieval.ipynb
notebooks/sam2-image-segmentation/segment-anything-2-image.ipynb
notebooks/sam2-video-segmentation/segment-anything-2-video.ipynb
notebooks/sana-image-generation/sana-image-generation.ipynb
notebooks/sdxl-turbo/sdxl-turbo.ipynb
notebooks/segment-anything/segment-anything.ipynb
notebooks/siglip-zero-shot-image-classification/siglip-zero-shot-image-classification.ipynb
Expand Down
Loading

0 comments on commit 842a81d

Please sign in to comment.