File size: 3,467 Bytes
6a83b17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
 "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
}