add fls
Browse files- LICENSE +13 -0
- attack.txt +0 -0
- count_attack.py +14 -0
- mijnEUROwm-OLD.ipynb +0 -0
- resize-and-rename-data.py +76 -0
LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2 |
+
Version 2, December 2004
|
3 |
+
|
4 |
+
Copyright (C) 2004 Sam Hocevar <[email protected]>
|
5 |
+
|
6 |
+
Everyone is permitted to copy and distribute verbatim or modified
|
7 |
+
copies of this license document, and changing it is allowed as long
|
8 |
+
as the name is changed.
|
9 |
+
|
10 |
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12 |
+
|
13 |
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
attack.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
count_attack.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
# https://www.cyberforum.ru/python-beginners/thread2510792.html
|
4 |
+
|
5 |
+
with open("attack.txt", "rt") as file:
|
6 |
+
text = file.read()
|
7 |
+
|
8 |
+
for digit in "6789":
|
9 |
+
print(f"{digit} {text.count(digit)}")
|
10 |
+
|
11 |
+
# 6 354
|
12 |
+
# 7 383
|
13 |
+
# 8 359
|
14 |
+
# 9 344
|
mijnEUROwm-OLD.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
resize-and-rename-data.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import PIL
|
2 |
+
from PIL import Image
|
3 |
+
import os, sys
|
4 |
+
import time
|
5 |
+
|
6 |
+
|
7 |
+
Width, Height = 480, 320
|
8 |
+
|
9 |
+
path1 = "DATASETs/wm5/"
|
10 |
+
color_mode1 = "L"
|
11 |
+
|
12 |
+
path2 = "DATASETs/cover5/"
|
13 |
+
color_mode2 = "RGB"
|
14 |
+
|
15 |
+
|
16 |
+
def resize(path, color_mode):
|
17 |
+
dirs = os.listdir(path)
|
18 |
+
print('before resize ', len(dirs))
|
19 |
+
for item in dirs:
|
20 |
+
try:
|
21 |
+
# print(item)
|
22 |
+
with Image.open(fr'{path}{item}') as im:
|
23 |
+
resized = im.convert(f'{color_mode}').resize((Width,Height))
|
24 |
+
resized.save(fr'{path}{item}')
|
25 |
+
time.sleep(0.0003)
|
26 |
+
# print(fr'for {item} have been done')
|
27 |
+
except PIL.UnidentifiedImageError:
|
28 |
+
print(fr"Confirmed: This image {path}{item} cannot be opened!")
|
29 |
+
# os.remove(f'{path}{item}')
|
30 |
+
except OSError:
|
31 |
+
im = Image.open(fr'{path}{item}').convert(f'{color_mode}').resize((Width,Height))
|
32 |
+
im.save(fr'{path}{item}')
|
33 |
+
print(fr"Chanched by hands for {path}{item}")
|
34 |
+
dirs = os.listdir(path)
|
35 |
+
print('after resize ', len(dirs))
|
36 |
+
|
37 |
+
|
38 |
+
resize(path1, color_mode1)
|
39 |
+
resize(path2, color_mode2)
|
40 |
+
|
41 |
+
|
42 |
+
def test_size(path):
|
43 |
+
dirs = os.listdir(path)
|
44 |
+
print('before test ', len(dirs))
|
45 |
+
for item in dirs:
|
46 |
+
try:
|
47 |
+
with Image.open(fr'{path}{item}') as im:
|
48 |
+
width, height = im.size
|
49 |
+
if (width == Width) and (height == Height):
|
50 |
+
pass
|
51 |
+
else:
|
52 |
+
print(fr'for {item} not true size')
|
53 |
+
time.sleep(0.0003)
|
54 |
+
except PIL.UnidentifiedImageError:
|
55 |
+
print(fr"Confirmed: This image {item} cannot be opened! We removed it")
|
56 |
+
os.remove(f'{path}{item}')
|
57 |
+
dirs = os.listdir(path)
|
58 |
+
print('after test ', len(dirs))
|
59 |
+
|
60 |
+
|
61 |
+
test_size(path1)
|
62 |
+
test_size(path2)
|
63 |
+
|
64 |
+
|
65 |
+
def renameimg(path):
|
66 |
+
os.getcwd()
|
67 |
+
# print(os.getcwd())
|
68 |
+
for i, filename in enumerate(os.listdir(path)):
|
69 |
+
try:
|
70 |
+
os.rename(path + "/" + filename, path + "/" + str(i) + ".jpeg")
|
71 |
+
|
72 |
+
except FileExistsError:
|
73 |
+
pass
|
74 |
+
|
75 |
+
renameimg(path1)
|
76 |
+
renameimg(path2)
|