Skip to content

Commit

Permalink
data loading ok, need to convert RGBA to RGB
Browse files Browse the repository at this point in the history
  • Loading branch information
volker-baecker committed Jan 20, 2025
1 parent 49f9cda commit 013b851
Show file tree
Hide file tree
Showing 2 changed files with 377 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "1f72240e-c42a-4a54-81d7-5c3eafd59002",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -248,22 +248,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "1eb53565-e3e1-46a1-8330-8646b8f06649",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: '/media/baecker/6b38a953-6650-4da5-94d9-57bd718df733/2025/in/2007_tree_rings/input_images/masks/patches'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 29\u001b[0m\n\u001b[1;32m 26\u001b[0m os\u001b[38;5;241m.\u001b[39mrename(imagePath, os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(imageOutFolder, imageName))\n\u001b[1;32m 27\u001b[0m counter \u001b[38;5;241m=\u001b[39m counter \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m\n\u001b[0;32m---> 29\u001b[0m \u001b[43mmain\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"Cell \u001b[0;32mIn[4], line 8\u001b[0m, in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m image_patches_folder \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(input_folder, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpatches\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 7\u001b[0m mask_patches_folder \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(masks_folder, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpatches\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m----> 8\u001b[0m masks \u001b[38;5;241m=\u001b[39m \u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlistdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmask_patches_folder\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 9\u001b[0m mask_paths \u001b[38;5;241m=\u001b[39m [os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(mask_patches_folder, file) \u001b[38;5;28;01mfor\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m masks \u001b[38;5;28;01mif\u001b[39;00m file\u001b[38;5;241m.\u001b[39mendswith(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.tif\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m file\u001b[38;5;241m.\u001b[39mendswith(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m)]\n\u001b[1;32m 10\u001b[0m image_paths \u001b[38;5;241m=\u001b[39m [os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(image_patches_folder, file) \u001b[38;5;28;01mfor\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m masks \u001b[38;5;28;01mif\u001b[39;00m file\u001b[38;5;241m.\u001b[39mendswith(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.tif\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m file\u001b[38;5;241m.\u001b[39mendswith(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m)]\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/media/baecker/6b38a953-6650-4da5-94d9-57bd718df733/2025/in/2007_tree_rings/input_images/masks/patches'"
]
}
],
"source": [
"import random \n",
"import numpy as np\n",
"import os\n",
"\n",
"def main():\n",
" image_patches_folder = os.path.join(input_folder, \"patches\")\n",
" mask_patches_folder = os.path.join(masks_folder, \"patches\")\n",
" masks = os.listdir(mask_patches_folder)\n",
" mask_paths = [os.path.join(mask_patches_folder, file) for file in masks if file.endswith(\".tif\") or file.endswith(\".jpg\")]\n",
" image_paths = [os.path.join(image_patches_folder, file) for file in masks if file.endswith(\".tif\") or file.endswith(\".jpg\")]\n",
" maskOutFolder = os.path.join(masks_folder, \"validation_patches\")\n",
" imageOutFolder = os.path.join(input_folder, \"validation_patches\")\n",
" maskOutFolder = os.path.join(masks_folder, \"test_patches\")\n",
" imageOutFolder = os.path.join(input_folder, \"test_patches\")\n",
" os.makedirs(maskOutFolder, exist_ok=True)\n",
" os.makedirs(imageOutFolder, exist_ok=True)\n",
" N = len(mask_paths)\n",
Expand All @@ -286,7 +300,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "aea50a10-165f-4c8d-9218-14e612fb0d89",
"id": "bddee775-b7f5-477f-996b-79a1e675d8a5",
"metadata": {},
"outputs": [],
"source": []
Expand Down
Loading

0 comments on commit 013b851

Please sign in to comment.