|
120 | 120 | "outputs": [],
|
121 | 121 | "source": [
|
122 | 122 | "# Import local modules\n",
|
| 123 | + "import requests\n", |
123 | 124 | "\n",
|
124 | 125 | "if not Path(\"./notebook_utils.py\").exists():\n",
|
125 | 126 | " # Fetch `notebook_utils` module\n",
|
126 |
| - " import requests\n", |
127 | 127 | "\n",
|
128 | 128 | " r = requests.get(\n",
|
129 | 129 | " url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
|
|
174 | 174 | "precision = \"FP16\"\n",
|
175 | 175 | "# The name of the model from Open Model Zoo\n",
|
176 | 176 | "detection_model_name = \"person-detection-0202\"\n",
|
177 |
| - "\n", |
178 |
| - "\n", |
179 | 177 | "download_det_model_url = (\n",
|
180 | 178 | " f\"https://storage.openvinotoolkit.org/repositories/open_model_zoo/2023.0/models_bin/1/{detection_model_name}/{precision}/{detection_model_name}.xml\"\n",
|
181 | 179 | ")\n",
|
| 180 | + "detection_model_path = Path(base_model_dir) / detection_model_name / precision / f\"{detection_model_name}.xml\"\n", |
182 | 181 | "\n",
|
183 |
| - "detection_model_path = download_ir_model(download_det_model_url, Path(base_model_dir) / detection_model_name / precision)\n", |
| 182 | + "if not detection_model_path.exists():\n", |
| 183 | + "\n", |
| 184 | + " download_ir_model(download_det_model_url, Path(base_model_dir) / detection_model_name / precision)\n", |
184 | 185 | "\n",
|
185 | 186 | "reidentification_model_name = \"person-reidentification-retail-0287\"\n",
|
186 | 187 | "download_reid_model_url = f\"https://storage.openvinotoolkit.org/repositories/open_model_zoo/2023.0/models_bin/1/{reidentification_model_name}/{precision}/{reidentification_model_name}.xml\"\n",
|
| 188 | + "reidentification_model_path = Path(base_model_dir) / reidentification_model_name / precision / f\"{reidentification_model_name}.xml\"\n", |
187 | 189 | "\n",
|
188 |
| - "reidentification_model_path = download_ir_model(download_reid_model_url, Path(base_model_dir) / reidentification_model_name / precision)" |
| 190 | + "if not reidentification_model_path.exists():\n", |
| 191 | + " download_ir_model(download_reid_model_url, Path(base_model_dir) / reidentification_model_name / precision)" |
189 | 192 | ]
|
190 | 193 | },
|
191 | 194 | {
|
|
449 | 452 | "source": [
|
450 | 453 | "base_file_link = \"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/image/person_\"\n",
|
451 | 454 | "image_indices = [\"1_1.png\", \"1_2.png\", \"2_1.png\"]\n",
|
452 |
| - "image_paths = [utils.download_file(base_file_link + image_index, directory=\"data\") for image_index in image_indices]\n", |
| 455 | + "image_paths = [\n", |
| 456 | + " utils.download_file(base_file_link + image_index, directory=\"data\") for image_index in image_indices if not (Path(\"data\") / image_index).exists()\n", |
| 457 | + "]\n", |
453 | 458 | "image1, image2, image3 = [cv2.cvtColor(cv2.imread(str(image_path)), cv2.COLOR_BGR2RGB) for image_path in image_paths]\n",
|
454 | 459 | "\n",
|
455 | 460 | "# Define titles with images.\n",
|
|
705 | 710 | "USE_WEBCAM = False\n",
|
706 | 711 | "\n",
|
707 | 712 | "cam_id = 0\n",
|
708 |
| - "video_file = \"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/video/people.mp4\"\n", |
| 713 | + "video_url = \"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/video/people.mp4\"\n", |
| 714 | + "video_file = Path(\"people.mp4\")\n", |
709 | 715 | "source = cam_id if USE_WEBCAM else video_file\n",
|
710 | 716 | "\n",
|
| 717 | + "if not USE_WEBCAM and not video_file.exists():\n", |
| 718 | + " utils.download_file(video_url)\n", |
| 719 | + "\n", |
711 | 720 | "run_person_tracking(source=source, flip=USE_WEBCAM, use_popup=False)"
|
712 | 721 | ]
|
713 | 722 | }
|
|
0 commit comments