From 1337222ff040d021642f7f0a54dc3ed4eb1635c3 Mon Sep 17 00:00:00 2001 From: healthonrails Date: Fri, 6 Dec 2024 17:44:57 -0500 Subject: [PATCH] feat: add functionality to zip and download 'runs' folder with saved best models --- annolid/segmentation/yolos.py | 2 +- ...ance_Segmentation_on_YOLO11_Tutorial.ipynb | 47 +++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/annolid/segmentation/yolos.py b/annolid/segmentation/yolos.py index dfb2567..65d4f67 100644 --- a/annolid/segmentation/yolos.py +++ b/annolid/segmentation/yolos.py @@ -175,5 +175,5 @@ def save_yolo_to_labelme(self, yolo_results, frame_shape, output_dir): video_path = os.path.expanduser("~/Downloads/IMG_0769.MOV") # Automatically find best.pt or use default - yolo_processor = InferenceProcessor(model_type="yolo") + yolo_processor = InferenceProcessor("yolo11n-seg.pt",model_type="yolo") yolo_processor.run_inference(video_path) diff --git a/docs/tutorials/Annolid_Instance_Segmentation_on_YOLO11_Tutorial.ipynb b/docs/tutorials/Annolid_Instance_Segmentation_on_YOLO11_Tutorial.ipynb index 5fca3cc..ff3174f 100644 --- a/docs/tutorials/Annolid_Instance_Segmentation_on_YOLO11_Tutorial.ipynb +++ b/docs/tutorials/Annolid_Instance_Segmentation_on_YOLO11_Tutorial.ipynb @@ -48,6 +48,19 @@ "execution_count": null, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "import shutil\n", + "import os\n", + "from google.colab import files" + ], + "metadata": { + "id": "fJwI06VXAd5l" + }, + "execution_count": null, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -60,7 +73,6 @@ { "cell_type": "code", "source": [ - "from google.colab import files\n", "custom_dataset = files.upload()" ], "metadata": { @@ -406,8 +418,6 @@ { "cell_type": "code", "source": [ - "import shutil\n", - "import os\n", "\n", "# Provide the path to the folder you want to zip\n", "folder_to_zip = output_dir # Update with your folder path\n", @@ -418,7 +428,8 @@ "# Zip the folder\n", "shutil.make_archive(folder_to_zip, 'zip', folder_to_zip)\n", "\n", - "print(f\"Folder '{folder_to_zip}' has been zipped to '{output_zip_file}'.\")" + "print(f\"Folder '{folder_to_zip}' has been zipped to '{output_zip_file}'.\")\n", + "files.download(output_zip_file)" ], "metadata": { "id": "T-OfoVvzWA4K" @@ -426,6 +437,34 @@ "execution_count": null, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Zip and download runs folder which continas the saved best model" + ], + "metadata": { + "id": "iUMFYuLk_waJ" + } + }, + { + "cell_type": "code", + "source": [ + "# Replace 'folder_name' with the name of your folder\n", + "folder_to_download = 'runs'\n", + "output_filename = 'runs.zip'\n", + "\n", + "# Compress the folder\n", + "shutil.make_archive(output_filename.replace('.zip', ''), 'zip', folder_to_download)\n", + "\n", + "# Download the zipped folder\n", + "files.download(output_filename)" + ], + "metadata": { + "id": "YuAW2iF8_jbq" + }, + "execution_count": null, + "outputs": [] + }, { "cell_type": "markdown", "source": [