Skip to content

Commit

Permalink
Fix for Kernel Failure in Style Transfer Notebook (#1958)
Browse files Browse the repository at this point in the history
This PR introduces a fix for the kernel failure observed during the CI
checks for the style transfer notebook. The failure was initially
reported in the linked Jira ticket CVS-115799.

The notebook has been tested using Treon as mentioned in the
contributing guidelines. The Treon log is attached for reference

[treon_style_transfer_results.log](https://github.com/openvinotoolkit/openvino_notebooks/files/15087700/treon_style_transfer_results.log)
.
  • Loading branch information
AnishaUdayakumar authored Apr 25, 2024
1 parent f43125b commit a86e8a6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
1 change: 0 additions & 1 deletion .ci/ignore_treon_docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ instant-id
stable-diffusion-keras-cv
tensorflow-training-openvino
tensorflow-quantization-aware-training
style-transfer-webcam
animate-anyone
llava-next-multimodal-chatbot
llm-rag-langchain
Expand Down
1 change: 0 additions & 1 deletion .ci/ignore_treon_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ kosmos2-multimodal-large-language-model
photo-maker
openvoice
instant-id
style-transfer-webcam
animate-anyone
llava-next-multimodal-chatbot
llm-rag-langchain
Expand Down
1 change: 0 additions & 1 deletion .ci/ignore_treon_mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ photo-maker
openvoice
instant-id
grounded-segment-anything
style-transfer-webcam
triposr-3d-reconstruction
animate-anyone
llava-next-multimodal-chatbot
Expand Down
46 changes: 29 additions & 17 deletions notebooks/style-transfer-webcam/style-transfer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"import cv2\n",
"import numpy as np\n",
"from pathlib import Path\n",
"from IPython import display\n",
"from ipywidgets import interactive, ToggleButtons\n",
"import ipywidgets as widgets\n",
"from IPython.display import display, clear_output, Image\n",
"import openvino as ov\n",
"\n",
"import notebook_utils as utils"
Expand All @@ -112,15 +112,27 @@
},
"outputs": [],
"source": [
"# Option to select different styles\n",
"styleButtons = ToggleButtons(\n",
"# Option to select different styles using a dropdown\n",
"style_dropdown = widgets.Dropdown(\n",
" options=[\"MOSAIC\", \"RAIN-PRINCESS\", \"CANDY\", \"UDNIE\", \"POINTILISM\"],\n",
" description=\"Click one of the styles you want to use for the style transfer\",\n",
" value=\"MOSAIC\", # Set the default value\n",
" description=\"Select Style:\",\n",
" disabled=False,\n",
" style={\"description_width\": \"300px\"},\n",
" style={\"description_width\": \"initial\"}, # Adjust the width as needed\n",
")\n",
"\n",
"interactive(lambda option: print(option), option=styleButtons)"
"\n",
"# Function to handle changes in dropdown and print the selected style\n",
"def print_style(change):\n",
" if change[\"type\"] == \"change\" and change[\"name\"] == \"value\":\n",
" print(f\"Selected style {change['new']}\")\n",
"\n",
"\n",
"# Observe changes in the dropdown value\n",
"style_dropdown.observe(print_style, names=\"value\")\n",
"\n",
"# Display the dropdown\n",
"display(style_dropdown)"
]
},
{
Expand Down Expand Up @@ -150,7 +162,7 @@
"base_url = \"https://github.com/onnx/models/raw/69d69010b7ed6ba9438c392943d2715026792d40/archive/vision/style_transfer/fast_neural_style/model\"\n",
"\n",
"# Selected ONNX model will be downloaded in the path\n",
"model_path = Path(f\"{styleButtons.value.lower()}-9.onnx\")\n",
"model_path = Path(f\"{style_dropdown.value.lower()}-9.onnx\")\n",
"\n",
"style_url = f\"{base_url}/{model_path}\"\n",
"utils.download_file(style_url, directory=base_model_dir)"
Expand Down Expand Up @@ -181,8 +193,8 @@
"source": [
"# Construct the command for model conversion API.\n",
"\n",
"ov_model = ov.convert_model(f\"model/{styleButtons.value.lower()}-9.onnx\")\n",
"ov.save_model(ov_model, f\"model/{styleButtons.value.lower()}-9.xml\")"
"ov_model = ov.convert_model(f\"model/{style_dropdown.value.lower()}-9.onnx\")\n",
"ov.save_model(ov_model, f\"model/{style_dropdown.value.lower()}-9.xml\")"
]
},
{
Expand All @@ -194,7 +206,7 @@
"outputs": [],
"source": [
"# Converted IR model path\n",
"ir_path = Path(f\"model/{styleButtons.value.lower()}-9.xml\")\n",
"ir_path = Path(f\"model/{style_dropdown.value.lower()}-9.xml\")\n",
"onnx_path = Path(f\"model/{model_path}\")"
]
},
Expand Down Expand Up @@ -477,10 +489,10 @@
" # Encode numpy array to jpg.\n",
" _, encoded_img = cv2.imencode(\".jpg\", result_image, params=[cv2.IMWRITE_JPEG_QUALITY, 90])\n",
" # Create an IPython image.\n",
" i = display.Image(data=encoded_img)\n",
" i = Image(data=encoded_img)\n",
" # Display the image in this notebook.\n",
" display.clear_output(wait=True)\n",
" display.display(i)\n",
" clear_output(wait=True)\n",
" display(i)\n",
" # ctrl-c\n",
" except KeyboardInterrupt:\n",
" print(\"Interrupted\")\n",
Expand Down Expand Up @@ -549,9 +561,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "openvino_env",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "openvino_env"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -563,7 +575,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
},
"openvino_notebooks": {
"imageUrl": "https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/style-transfer-webcam/style-transfer.gif?raw=true",
Expand Down

0 comments on commit a86e8a6

Please sign in to comment.