Skip to content

Commit

Permalink
feat: add functionality to zip and download 'runs' folder with saved …
Browse files Browse the repository at this point in the history
…best models
  • Loading branch information
healthonrails committed Dec 6, 2024
1 parent 17f88a4 commit 1337222
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion annolid/segmentation/yolos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -60,7 +73,6 @@
{
"cell_type": "code",
"source": [
"from google.colab import files\n",
"custom_dataset = files.upload()"
],
"metadata": {
Expand Down Expand Up @@ -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",
Expand All @@ -418,14 +428,43 @@
"# 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"
},
"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": [
Expand Down

0 comments on commit 1337222

Please sign in to comment.