1040 lines
28 KiB
Plaintext
1040 lines
28 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"import pandas as pd\n",
|
|
"import shutil\n",
|
|
"import json"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = pd.read_csv(r'C:\\Users\\PC\\Desktop\\wko_test_data\\train\\_classes.csv', encoding='utf-8')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for category in list(data.columns[1:]):\n",
|
|
" os.mkdir(f\"./data/train/{category.strip().capitalize()}\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 32,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for file in data.iloc:\n",
|
|
" file_name = file[0]\n",
|
|
" for item in list(file.items())[1:]:\n",
|
|
" if item[1]:\n",
|
|
" shutil.copyfile(rf'C:\\Users\\PC\\Desktop\\wko_test_data\\train\\{file_name}', f'./data/train/{item[0].strip().capitalize()}/{file_name}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 33,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data_test = pd.read_csv(r'C:\\Users\\PC\\Desktop\\wko_test_data\\test\\_classes.csv', encoding='utf-8')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 38,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"results = []\n",
|
|
"for file in data_test.iloc:\n",
|
|
" file_name = file[0]\n",
|
|
" for item in list(file.items())[1:]:\n",
|
|
" shutil.copyfile(rf'C:\\Users\\PC\\Desktop\\wko_test_data\\test\\{file_name}', f'./data/test/{file_name}')\n",
|
|
" if item[1]:\n",
|
|
" results.append({'filename': file_name, \"value\": item[0].strip().capitalize()})\n",
|
|
" continue\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open(\"./data/test_label.json\", 'w', encoding='utf-8') as f:\n",
|
|
" json.dump(results, f)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data_count = len(os.listdir(r'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped'))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"3362"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"round(data_count *0.8)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"results = []"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"os.listdir(r'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for fish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped')[:3362]:\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped\\{fish}', f'./new_data/train/Fish/{fish}')\n",
|
|
"for fish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped')[3363:]:\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\Fish_Data\\images\\cropped\\{fish}', f'./new_data/test/{fish}')\n",
|
|
" results.append({'filename': fish, \"value\": 'Fish'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for jellyfish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\jellyfish\\data\\val\\animal_jellyfish'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\jellyfish\\data\\val\\animal_jellyfish\\{jellyfish}', f'./new_data/train/Jellyfish/{jellyfish}')\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for jellyfish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\jellyfish\\data\\test\\animal_jellyfish'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\jellyfish\\data\\test\\animal_jellyfish\\{jellyfish}', f'./new_data/test/{jellyfish}')\n",
|
|
" results.append({'filename': jellyfish, \"value\": 'Jellyfish'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for lionfish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\lionfish\\data\\val\\lionfish'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\lionfish\\data\\val\\lionfish\\{lionfish}', f'./new_data/train/Lionfish/{lionfish}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for lionfish in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\lionfish\\data\\test\\lionfish'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\lionfish\\data\\test\\lionfish\\{lionfish}', f'./new_data/test/{lionfish}')\n",
|
|
" results.append({'filename': lionfish, \"value\": 'Lionfish'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for shark in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\shark\\data\\val\\animal_shark'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\shark\\data\\val\\animal_shark\\{shark}', f'./new_data/train/Shark/{shark}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for shark in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\shark\\data\\test\\animal_shark'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\shark\\data\\test\\animal_shark\\{shark}', f'./new_data/test/{shark}')\n",
|
|
" results.append({'filename': shark, \"value\": 'Shark'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for stingray in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\stingray\\data\\val\\stingray'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\stingray\\data\\val\\stingray\\{stingray}', f'./new_data/train/Stingray/{stingray}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for stingray in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\stingray\\data\\test\\stingray'):\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\stingray\\data\\test\\stingray\\{stingray}', f'./new_data/test/{stingray}')\n",
|
|
" results.append({'filename': stingray, \"value\": 'Stingray'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"1582"
|
|
]
|
|
},
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"round(len(os.listdir(r'D:\\Michal\\studia\\wk_project_data\\turtle\\images')) *0.8)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for turtle in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\turtle\\images')[:600]:\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\turtle\\images\\{turtle}', f'./new_data/train/Turtle/{turtle}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for turtle in os.listdir(r'D:\\Michal\\studia\\wk_project_data\\turtle\\images')[600:700]:\n",
|
|
" shutil.copyfile(rf'D:\\Michal\\studia\\wk_project_data\\turtle\\images\\{turtle}', f'./new_data/test/{turtle}')\n",
|
|
" results.append({'filename': turtle, \"value\": 'Turtle'})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open(\"./new_data/test_labels.json\", 'w', encoding='utf-8') as f:\n",
|
|
" json.dump(results, f)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import cv2 as cv\n",
|
|
"from skimage.io import imread"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 35,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"results = []"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 36,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"for dir in os.listdir('./new_data/train'):\n",
|
|
" for item in os.listdir(f'./new_data/train/{dir}'):\n",
|
|
" a = imread(f'./new_data/train/{dir}/{item}')\n",
|
|
" if len(a.shape) != 3:\n",
|
|
" results.append(f'./new_data/train/{dir}/{item}')\n",
|
|
" # os.remove(f'./new_data/train/{dir}/{item}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 37,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"0"
|
|
]
|
|
},
|
|
"execution_count": 37,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"len(results)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 39,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"res = []"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"for dir in os.listdir('./new_data/test'):\n",
|
|
" a = imread(f'./new_data/test/{dir}')\n",
|
|
" if len(a.shape) != 3:\n",
|
|
" # os.remove(f'./new_data/test/{dir}')\n",
|
|
" results.append(f'./new_data/test/{dir}')\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 41,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"0"
|
|
]
|
|
},
|
|
"execution_count": 41,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"len(res)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 42,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 53,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"1961 1902\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"new_data = []\n",
|
|
"with open('./new_data/test_labels.json', 'r', encoding='utf-8') as f:\n",
|
|
" data= json.load(f)\n",
|
|
" files = os.listdir(\"./new_data/test\")\n",
|
|
" new_data = list(filter(lambda x: x['filename'] in files, data))\n",
|
|
" print(len(data), len(new_data))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 55,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open('./new_data/test_labels2.json', 'w', encoding='utf-8') as f:\n",
|
|
" json.dump(new_data, f)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 62,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"600"
|
|
]
|
|
},
|
|
"execution_count": 62,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"len(os.listdir('./new_data/train/Turtle/'))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 82,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"r = {}\n",
|
|
"for data in os.listdir(\"./new_data_2/train\"):\n",
|
|
" r[data] = len(os.listdir(f\"./new_data_2/train/{data}\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 83,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'Fish': 300,\n",
|
|
" 'Jellyfish': 300,\n",
|
|
" 'Lionfish': 300,\n",
|
|
" 'Shark': 300,\n",
|
|
" 'Stingray': 300,\n",
|
|
" 'Turtle': 300}"
|
|
]
|
|
},
|
|
"execution_count": 83,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"r"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 84,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"306"
|
|
]
|
|
},
|
|
"execution_count": 84,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"len(os.listdir(\"./new_data_2/test/\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 71,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import shutil\n",
|
|
"import json\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 81,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"results = []\n",
|
|
"for type in os.listdir(\"./new_data/train\"):\n",
|
|
" count = 1\n",
|
|
" os.mkdir(f\"./new_data_2/train/{type}\")\n",
|
|
" for file in os.listdir(f\"./new_data/train/{type}\"):\n",
|
|
" if count <= 300:\n",
|
|
" shutil.copyfile(f\"./new_data/train/{type}/{file}\", f'./new_data_2/train/{type}/{file}')\n",
|
|
" if count <= 350 and count >= 300:\n",
|
|
" shutil.copyfile(f\"./new_data/train/{type}/{file}\", f'./new_data_2/test/{file}')\n",
|
|
" results.append({'filename': file, \"value\": type})\n",
|
|
" if count >= 350:\n",
|
|
" break\n",
|
|
" count += 1\n",
|
|
"with open(\"./new_data_2/test_labels.json\", \"w\", encoding='utf-8') as f:\n",
|
|
" json.dump(results, f)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 85,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"306\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"with open(\"./new_data_2/test_labels.json\", \"r\", encoding='utf-8') as f:\n",
|
|
" print(len(json.load(f)))\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"['Fish', 'Jellyfish', 'Lionfish', 'Shark', 'Stingray', 'Turtle']"
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"sorted(os.listdir('./new_data_2/train/'))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os, shutil, json"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"284"
|
|
]
|
|
},
|
|
"execution_count": 14,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from skimage.io import imread\n",
|
|
"\n",
|
|
"count = 0\n",
|
|
"for fish in os.listdir(\"../wk_project_data/Fish_Data/images/raw_images/\"):\n",
|
|
" a = imread(f'../wk_project_data/Fish_Data/images/raw_images/{fish}')\n",
|
|
" if len(a.shape) != 3:\n",
|
|
" os.remove(f'../wk_project_data/Fish_Data/images/raw_images/{fish}')\n",
|
|
" count +=1\n",
|
|
"count"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# old = os.listdir(\"./new_data_2/train/Fish/\")\n",
|
|
"for fish in os.listdir('../wk_project_data/Fish_Data/images/raw_images/')[:300]:\n",
|
|
" shutil.copyfile(f'../wk_project_data/Fish_Data/images/raw_images/{fish}', f'./new_data_2/train/Fish/{fish}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 27,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"255 305\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"results = []\n",
|
|
"with open(\"./new_data_2/test_labels.json\", \"r\", encoding='utf-8') as f:\n",
|
|
" a = json.load(f)\n",
|
|
" results = list(filter(lambda x: x['value'] != \"Fish\", a))\n",
|
|
" for fish in os.listdir('../wk_project_data/Fish_Data/images/raw_images/')[301:351]:\n",
|
|
" shutil.copyfile(f'../wk_project_data/Fish_Data/images/raw_images/{fish}', f'./new_data_2/test/{fish}')\n",
|
|
" results.append({'filename': fish, \"value\": 'Fish'})\n",
|
|
"print(len(a), len(results))\n",
|
|
"# for fish in os.listdir('./new_data_2/test/'):\n",
|
|
"# if fish not in [res['filename'] for res in results]:\n",
|
|
"# os.remove(f'./new_data_2/test/{fish}')\n",
|
|
"with open('./new_data_2/test_labels2.json', 'w', encoding='utf-8') as f:\n",
|
|
" json.dump(results, f)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"305"
|
|
]
|
|
},
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"len(os.listdir(\"./new_data_2/test/\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"255\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"results = []\n",
|
|
"old = os.listdir(\"./new_data_2/test/\")\n",
|
|
"with open(\"./new_data_2/test_labels.json\", \"r\", encoding='utf-8') as f:\n",
|
|
" a = json.load(f)\n",
|
|
" print(len(a))\n",
|
|
" results = list(filter(lambda x: x['value'] != \"Fish\", a))\n",
|
|
" # print(len(a), len(results))\n",
|
|
" # for file in old:\n",
|
|
" # if file not in [res['filename'] for res in results]:\n",
|
|
" # os.remove(f'./new_data_2/test/{file}')\n",
|
|
"# with open('./new_data_2/test_labels2.json', 'w', encoding='utf-8') as f:\n",
|
|
"# json.dump(results, f)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"['aseraggodes_melanostictus_2.jpg',\n",
|
|
" 'aseraggodes_melanostictus_3.jpg',\n",
|
|
" 'atractoscion_aequidens_1.jpg',\n",
|
|
" 'atractoscion_aequidens_2.jpg',\n",
|
|
" 'atractoscion_aequidens_3.jpg',\n",
|
|
" 'atractoscion_aequidens_4.jpg',\n",
|
|
" 'atractoscion_aequidens_5.jpg',\n",
|
|
" 'atule_mate_1.jpg',\n",
|
|
" 'atule_mate_2.jpg',\n",
|
|
" 'atule_mate_3.jpg',\n",
|
|
" 'atule_mate_4.jpg',\n",
|
|
" 'atule_mate_5.jpg',\n",
|
|
" 'atule_mate_6.jpg',\n",
|
|
" 'auxis_rochei_1.jpg',\n",
|
|
" 'auxis_rochei_2.jpg',\n",
|
|
" 'auxis_rochei_3.jpg',\n",
|
|
" 'auxis_rochei_4.jpg',\n",
|
|
" 'auxis_rochei_5.jpg',\n",
|
|
" 'auxis_rochei_6.jpg',\n",
|
|
" 'auxis_thazard_1.jpg',\n",
|
|
" 'auxis_thazard_2.jpg',\n",
|
|
" 'auxis_thazard_3.jpg',\n",
|
|
" 'auxis_thazard_4.jpg',\n",
|
|
" 'auxis_thazard_5.jpg',\n",
|
|
" 'auxis_thazard_6.jpg',\n",
|
|
" 'auxis_thazard_7.jpg',\n",
|
|
" 'auxis_thazard_8.jpg',\n",
|
|
" 'BA472025AZL8.jpg',\n",
|
|
" 'BA5BMQ2M6X2R.jpg',\n",
|
|
" 'bathylagichthys_greyae_1.jpg',\n",
|
|
" 'bathylagichthys_greyae_2.jpg',\n",
|
|
" 'bathylagichthys_greyae_3.jpg',\n",
|
|
" 'BBUVLQAWO2J9.jpg',\n",
|
|
" 'BCNZZANYP0ZV.jpg',\n",
|
|
" 'BCTT754FXP33.jpg',\n",
|
|
" 'beryx_decadactylus_1.jpg',\n",
|
|
" 'beryx_decadactylus_2.jpg',\n",
|
|
" 'beryx_decadactylus_3.jpg',\n",
|
|
" 'beryx_decadactylus_4.jpg',\n",
|
|
" 'beryx_decadactylus_5.jpg',\n",
|
|
" 'beryx_decadactylus_6.jpg',\n",
|
|
" 'BFFL4FUMTZA5.jpg',\n",
|
|
" 'BG9GN3HB8COL.jpg',\n",
|
|
" 'BIGHPAJBP3PN.jpg',\n",
|
|
" 'BNBTC6NUO815.jpg',\n",
|
|
" 'bodianus_anthioides_1.jpg',\n",
|
|
" 'bodianus_anthioides_10.jpg',\n",
|
|
" 'bodianus_anthioides_11.jpg',\n",
|
|
" 'bodianus_anthioides_12.jpg',\n",
|
|
" 'bodianus_anthioides_13.jpg',\n",
|
|
" 'bodianus_anthioides_14.jpg',\n",
|
|
" 'bodianus_anthioides_15.jpg',\n",
|
|
" 'bodianus_anthioides_2.jpg',\n",
|
|
" 'bodianus_anthioides_3.jpg',\n",
|
|
" 'bodianus_anthioides_4.jpg',\n",
|
|
" 'bodianus_anthioides_5.jpg',\n",
|
|
" 'bodianus_anthioides_6.jpg',\n",
|
|
" 'bodianus_anthioides_7.jpg',\n",
|
|
" 'bodianus_anthioides_8.jpg',\n",
|
|
" 'BS58RK9Y7XRW.jpg',\n",
|
|
" 'BSCIMPOKX5GB.jpg',\n",
|
|
" 'BY2BTSPMY9A3.jpg',\n",
|
|
" 'BYDA62T1MQNH.jpg',\n",
|
|
" 'BYXDM7G9SR9B.jpg',\n",
|
|
" 'BZYALDS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FEVFRGXYSUU6.jpg',\n",
|
|
" 'FFNAZQFD3LLQ.jpg',\n",
|
|
" 'FHD32EQTSRU0.jpg',\n",
|
|
" 'FHRAQBEA0JZ5.jpg',\n",
|
|
" 'FJ366SFC1JU2.jpg',\n",
|
|
" 'FJ3BLKK45MYN.jpg',\n",
|
|
" 'FJC6HC5R1D1R.jpg',\n",
|
|
" 'FJYSJ1FGD4MA.jpg',\n",
|
|
" 'FK3PTI29V78G.jpg',\n",
|
|
" 'FKP2F8SVMAB2.jpg',\n",
|
|
" 'FMWHH78S82D3.jpg',\n",
|
|
" 'FNSK9HQV1QY5.jpg',\n",
|
|
" 'FQENFKQ5F297.jpg',\n",
|
|
" 'Image_127.jpg',\n",
|
|
" 'Image_1270.jpg',\n",
|
|
" 'Image_1271.png',\n",
|
|
" 'Image_1272.jpg',\n",
|
|
" 'Image_1273.jpg',\n",
|
|
" 'Image_1274.jpg',\n",
|
|
" 'Image_1275.jpg',\n",
|
|
" 'Image_1276.jpg',\n",
|
|
" 'Image_1277.jpg',\n",
|
|
" 'Image_1278.png',\n",
|
|
" 'Image_1279.jpg',\n",
|
|
" 'Image_128.jpg',\n",
|
|
" 'Image_1280.jpg',\n",
|
|
" 'Image_1281.jpg',\n",
|
|
" 'Image_1282.jpg',\n",
|
|
" 'Image_1283.jpg',\n",
|
|
" 'Image_1284.jpg',\n",
|
|
" 'Image_1285.jpg',\n",
|
|
" 'Image_1286.jpg',\n",
|
|
" 'Image_1287.jpg',\n",
|
|
" 'Image_1288.jpg',\n",
|
|
" 'Image_1289.jpg',\n",
|
|
" 'Image_129.jpg',\n",
|
|
" 'Image_1290.jpg',\n",
|
|
" 'Image_1291.jpg',\n",
|
|
" 'Image_1292.jpg',\n",
|
|
" 'Image_1293.jpg',\n",
|
|
" 'Image_1294.jpg',\n",
|
|
" 'Image_1295.jpg',\n",
|
|
" 'Image_1296.jpg',\n",
|
|
" 'Image_1297.jpg',\n",
|
|
" 'Image_1298.jpg',\n",
|
|
" 'Image_1299.jpg',\n",
|
|
" 'Image_13.jpg',\n",
|
|
" 'Image_130.jpg',\n",
|
|
" 'Image_1300.jpg',\n",
|
|
" 'Image_1301.jpg',\n",
|
|
" 'Image_1302.jpg',\n",
|
|
" 'Image_1303.jpg',\n",
|
|
" 'Image_1304.jpg',\n",
|
|
" 'Image_1305.jpg',\n",
|
|
" 'Image_1306.jpg',\n",
|
|
" 'Image_1307.jpg',\n",
|
|
" 'Image_1308.jpg',\n",
|
|
" 'Image_1309.jpg',\n",
|
|
" 'Image_131.jpg',\n",
|
|
" 'Image_1310.png',\n",
|
|
" 'Image_1311.jpg',\n",
|
|
" 'Image_1312.jpg',\n",
|
|
" 'Image_1313.jpg',\n",
|
|
" 'Image_1314.jpg',\n",
|
|
" 'QPTNNR883Y71.jpg',\n",
|
|
" 'QYZKHFUZBYB5.jpg',\n",
|
|
" 'R7CE93VYTQ3C.jpg',\n",
|
|
" 'RFIF55SSBAJE.jpg',\n",
|
|
" 'RGFV4ID1FG4H.jpg',\n",
|
|
" 'RIMV8RD0O91K.jpg',\n",
|
|
" 'RP03D3135F0X.jpg',\n",
|
|
" 'RQTETBPA6LCE.jpg',\n",
|
|
" 'RUKD3M79DOW0.jpg',\n",
|
|
" 'RX52IW9OJ76K.jpg',\n",
|
|
" 'RYMXETE0HNP1.jpg',\n",
|
|
" 'S0H88RI2WWWG.jpg',\n",
|
|
" 'S4NVLRSGZ80O.jpg',\n",
|
|
" 'S5J21NY90AEU.jpg',\n",
|
|
" 'S6BGCT3174NY.jpg',\n",
|
|
" 'S7XQ2ZWU4XRQ.jpg',\n",
|
|
" 'SA6VWMCVZ0DZ.jpg',\n",
|
|
" 'SCBJ47X6E43S.jpg',\n",
|
|
" 'SCL4N9GWCRVO.jpg',\n",
|
|
" 'SDT00RQTLX26.jpg',\n",
|
|
" 'SEV5J90SU4YF.jpg',\n",
|
|
" 'SFOU9AI3AC8X.jpg',\n",
|
|
" 'SGN4LLDEANEJ.jpg',\n",
|
|
" 'S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I2.jpg',\n",
|
|
" 'VZMJF0JU6BJY.jpg',\n",
|
|
" 'W0WUDCV7HORQ.jpg',\n",
|
|
" 'W1S4LFQY8ZEP.jpg',\n",
|
|
" 'W8ADO53ZUWVX.jpg']"
|
|
]
|
|
},
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"old"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "um",
|
|
"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.15 | packaged by conda-forge | (main, Nov 22 2022, 08:41:22) [MSC v.1929 64 bit (AMD64)]"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "876e189cbbe99a9a838ece62aae1013186c4bb7e0254a10cfa2f9b2381853efb"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|