{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "data_path = \".\"\n", "import os\n", "import sys" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def file_exists_and_not_empty(filepath):\n", " return os.path.isfile(filepath) and os.path.getsize(filepath) > 0\n", "\n", "def check_example_complement(example_path):\n", " input_path = example_path + \"/input\"\n", " output_path = example_path + \"/output\"\n", " config_path = example_path + \"/env_config\"\n", " if not os.path.exists(input_path) or not os.path.exists(output_path) or not os.path.exists(config_path):\n", " return False\n", " input_pic_file = input_path + \"/input.png\"\n", " input_pic_gt_file = input_path + \"/input_mask.png\"\n", " input_instruction = input_path + \"/instruction.txt\"\n", " output_json = output_path + \"/operation_sequence.json\"\n", " config_json = config_path + \"/env_config.json\"\n", " if not file_exists_and_not_empty(input_pic_file) or not file_exists_and_not_empty(input_instruction) or not file_exists_and_not_empty(output_json) or not file_exists_and_not_empty(input_pic_gt_file) or not file_exists_and_not_empty(config_json):\n", " return False\n", " return True" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "All examples are complete!\n", "Number of examples: 4500\n" ] } ], "source": [ "error_example_list = {}\n", "number_of_exapmles = 0\n", "\n", "dim_list = os.listdir(data_path)\n", "for dim in dim_list:\n", " if dim == \"data_complement_check.ipynb\":\n", " continue\n", " for task in os.listdir(data_path + \"/\" + dim):\n", " exapmle_list = os.listdir(data_path + \"/\" + dim + \"/\" + task)\n", " for example in exapmle_list:\n", " if not check_example_complement(data_path + \"/\" + dim+ \"/\" + task + \"/\" + example):\n", " if task not in error_example_list:\n", " error_example_list[task] = []\n", " error_example_list[task].append(example)\n", " else:\n", " number_of_exapmles += 1\n", "\n", "if len(error_example_list) == 0:\n", " print(\"All examples are complete!\")\n", " print(\"Number of examples: \" + str(number_of_exapmles))\n", "else:\n", " print(\"Number of Normal examples: \" + str(number_of_exapmles))\n", " print(\"Some examples are incomplete!\")\n", " for task in error_example_list:\n", " print(\"Task: \" + task)\n", " for example in error_example_list[task]:\n", " print(\"Example: \" + example)\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "LM4", "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.9.19" } }, "nbformat": 4, "nbformat_minor": 2 }