shreyanshu09
commited on
Delete symbol_detection/png_to_jpg.ipynb
Browse files
symbol_detection/png_to_jpg.ipynb
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 2,
|
6 |
-
"id": "3bbfe9e4-c965-494a-a392-276c708d58d6",
|
7 |
-
"metadata": {},
|
8 |
-
"outputs": [],
|
9 |
-
"source": [
|
10 |
-
"from PIL import Image\n",
|
11 |
-
"import os\n",
|
12 |
-
"\n",
|
13 |
-
"directory = './mydata/Handwritten_block_diagrams/FC_A/test_img'\n",
|
14 |
-
"save = './mydata/Handwritten_block_diagrams/FC_A/test_jpg'\n",
|
15 |
-
"\n",
|
16 |
-
"for filename in os.listdir(directory):\n",
|
17 |
-
" if filename.endswith('.png'):\n",
|
18 |
-
" img = Image.open(os.path.join(directory, filename))\n",
|
19 |
-
" img = img.convert(\"RGB\")\n",
|
20 |
-
" img.save(os.path.join(save, filename[:-4] + '.jpg'), 'JPEG', quality=100)\n"
|
21 |
-
]
|
22 |
-
},
|
23 |
-
{
|
24 |
-
"cell_type": "code",
|
25 |
-
"execution_count": 2,
|
26 |
-
"id": "48f6e756-d81d-4491-84be-98661625988b",
|
27 |
-
"metadata": {},
|
28 |
-
"outputs": [],
|
29 |
-
"source": [
|
30 |
-
"import os\n",
|
31 |
-
"\n",
|
32 |
-
"# 指定目录路径\n",
|
33 |
-
"dir_path = './mydata/Handwritten_block_diagrams/FC_B/test_img'\n",
|
34 |
-
"\n",
|
35 |
-
"# 遍历目录下的所有文件和文件夹\n",
|
36 |
-
"for root, dirs, files in os.walk(dir_path):\n",
|
37 |
-
" # 遍历当前目录下的所有文件\n",
|
38 |
-
" for file in files:\n",
|
39 |
-
" # 判断文件扩展名是否为.png\n",
|
40 |
-
" if file.endswith('.jpg'):\n",
|
41 |
-
" # 构造文件的绝对路径\n",
|
42 |
-
" file_path = os.path.join(root, file)\n",
|
43 |
-
" # 删除文件\n",
|
44 |
-
" os.remove(file_path)\n"
|
45 |
-
]
|
46 |
-
},
|
47 |
-
{
|
48 |
-
"cell_type": "code",
|
49 |
-
"execution_count": null,
|
50 |
-
"id": "554bf8c4-68d3-490d-9ffd-f632b78e8b95",
|
51 |
-
"metadata": {},
|
52 |
-
"outputs": [],
|
53 |
-
"source": []
|
54 |
-
}
|
55 |
-
],
|
56 |
-
"metadata": {
|
57 |
-
"kernelspec": {
|
58 |
-
"display_name": "donut",
|
59 |
-
"language": "python",
|
60 |
-
"name": "donut"
|
61 |
-
},
|
62 |
-
"language_info": {
|
63 |
-
"codemirror_mode": {
|
64 |
-
"name": "ipython",
|
65 |
-
"version": 3
|
66 |
-
},
|
67 |
-
"file_extension": ".py",
|
68 |
-
"mimetype": "text/x-python",
|
69 |
-
"name": "python",
|
70 |
-
"nbconvert_exporter": "python",
|
71 |
-
"pygments_lexer": "ipython3",
|
72 |
-
"version": "3.7.15"
|
73 |
-
}
|
74 |
-
},
|
75 |
-
"nbformat": 4,
|
76 |
-
"nbformat_minor": 5
|
77 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|