Newer
Older
Yolov5WhiteLineDetection / notebooks / maketxt.ipynb
@sato sato on 1 Mar 2022 1 KB 最初のコミット
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "99515e03-8050-4840-94a9-2835e632ec2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from glob import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1a8ed63a-bed1-4048-b674-abeb771d0560",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_path = \"D:\\Deep_Learning\\yolov5\\whitelines\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fee368d8-4df9-4325-8f04-e76b194768c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "for phase in [\"train\", \"val\", \"test\"]:\n",
    "    f = open(f\"{phase}.txt\", \"w\")\n",
    "    for abs_path in glob(os.path.join(base_path, phase, \"images\", \"*\")):\n",
    "        # rel_path = abs_path.replace(f\"{base_path}\\\\\", \"\")\n",
    "        rel_path = abs_path\n",
    "        f.write(rel_path + \"\\n\")\n",
    "    f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abdce11e-b5fb-4852-a21b-dbcb3ee18a9a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}