Upload 11 files
Browse files- check.py +14 -0
- data.zip +3 -0
- figure_generate.py +119 -0
- label.zip +3 -0
- readme.md +21 -0
- sample/0000c1cd-30d9-42e8-82ae-9109ca6be939-label.png +3 -0
- sample/0000c1cd-30d9-42e8-82ae-9109ca6be939.png +3 -0
- sample/0000c1cd-30d9-42e8-82ae-9109ca6be939.txt +1 -0
- sample/000adad0-657b-4ce4-93d2-159f3ca80798-label.png +3 -0
- sample/000adad0-657b-4ce4-93d2-159f3ca80798.png +3 -0
- sample/000adad0-657b-4ce4-93d2-159f3ca80798.txt +1 -0
check.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
label_path = "label"
|
4 |
+
label_files = set([os.path.splitext(file)[0] for file in os.listdir(label_path) if file.endswith(".png")])
|
5 |
+
|
6 |
+
data_path = "data"
|
7 |
+
data_files = set([os.path.splitext(file)[0] for file in os.listdir(data_path) if file.endswith(".png")])
|
8 |
+
txt_files = set([os.path.splitext(file)[0] for file in os.listdir(data_path) if file.endswith(".txt")])
|
9 |
+
|
10 |
+
|
11 |
+
if label_files==data_files:
|
12 |
+
print("data_files")
|
13 |
+
if label_files==txt_files:
|
14 |
+
print("txt_files")
|
data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf5218c09fa967674956541bec37f30052424e2b8a6dc674d22154f99b45fe17
|
3 |
+
size 4116366493
|
figure_generate.py
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image, ImageDraw, ImageFilter
|
2 |
+
import numpy as np
|
3 |
+
import random
|
4 |
+
|
5 |
+
class SimplePolygon:
|
6 |
+
pow2 = None
|
7 |
+
|
8 |
+
def __init__(self, file_name, depth_name, tags_name,resolution=(512, 512), init_color=(255, 255, 255)):
|
9 |
+
self.file_name = file_name
|
10 |
+
self.depth_name = depth_name
|
11 |
+
self.tags_name = tags_name
|
12 |
+
self.width = resolution[0]
|
13 |
+
self.height = resolution[1]
|
14 |
+
self.components= [set([(wi, hi) for wi in range(512) for hi in range(512)])]
|
15 |
+
self.img1 = np.full((self.width, self.height, 3), np.random.randint(0, 256, size=(3,), dtype=np.uint8), dtype=np.uint8)
|
16 |
+
self.img2 = np.zeros([self.width, self.height, 3], dtype=np.uint8)
|
17 |
+
self.count = 0
|
18 |
+
if self.pow2 is None:
|
19 |
+
self.pow2 = [x**2 for x in range(max(resolution[0],resolution[1])+1)]
|
20 |
+
|
21 |
+
def generate(self):
|
22 |
+
layer = np.zeros_like(self.components, dtype=np.uint16)
|
23 |
+
noise = np.zeros(3, dtype=np.int16)
|
24 |
+
if random.randint(1, 5)==1:
|
25 |
+
noise = np.random.randint(-10, 10, size=(3,), dtype=np.int16)
|
26 |
+
for i in range(len(self.components)):
|
27 |
+
for j in range(i-1, -1, -1):
|
28 |
+
if not self.components[i].isdisjoint(self.components[j]):
|
29 |
+
layer[i]=layer[j]+1
|
30 |
+
color = np.random.randint(0, 255, size=(3,), dtype=np.int16)
|
31 |
+
vec = np.random.randint(0, 255, size=(3,), dtype=np.int16)
|
32 |
+
ep = np.random.normal(0, 2, size=(2,))
|
33 |
+
for wi, hi in self.components[i]:
|
34 |
+
self.img1[wi][hi] = np.abs((color + vec * (ep[0] * wi / self.width + ep[1] * hi / self.height)+noise) % 512 - 256).astype(np.uint8)
|
35 |
+
break
|
36 |
+
self.layer_max = np.max(layer)
|
37 |
+
normalized_layer = ( (255 * layer) // self.layer_max).astype(np.uint8)
|
38 |
+
for wi in range(self.width):
|
39 |
+
for hi in range(self.height):
|
40 |
+
for i in range(len(self.components)-1, -1, -1):
|
41 |
+
if (wi,hi) in self.components[i]:
|
42 |
+
self.img2[wi][hi][0] = normalized_layer[i]
|
43 |
+
self.img2[wi][hi][1] = normalized_layer[i]
|
44 |
+
self.img2[wi][hi][2] = normalized_layer[i]
|
45 |
+
break
|
46 |
+
|
47 |
+
def add_rect(self):
|
48 |
+
left_top = [random.randint(0, self.width//10*9), random.randint(0, self.height//10*9)]
|
49 |
+
poly_width = random.randint(60, self.width//2)
|
50 |
+
poly_height = random.randint(60, self.height//2)
|
51 |
+
poly = set()
|
52 |
+
for wi in range(left_top[0], min(left_top[0]+poly_width, self.width)):
|
53 |
+
for hi in range(left_top[1], min(left_top[1]+poly_height, self.height)):
|
54 |
+
poly.add((wi, hi))
|
55 |
+
self.components.append(poly)
|
56 |
+
return poly
|
57 |
+
|
58 |
+
def add_ellipse(self):
|
59 |
+
center = [random.randint(self.width//10, self.width//10*9), random.randint(self.height//10, self.height//10*9)]
|
60 |
+
radius_width = random.randint(60, self.width//4)
|
61 |
+
radius_height = random.randint(60, self.height//4)
|
62 |
+
poly = set()
|
63 |
+
r = radius_width**2 * radius_height**2
|
64 |
+
h2 = radius_height**2
|
65 |
+
w2 = radius_width**2
|
66 |
+
for wi in range(self.width):
|
67 |
+
xx = h2 * self.pow2[abs(wi-center[0])]
|
68 |
+
if xx > r:
|
69 |
+
continue
|
70 |
+
for hi in range(self.height):
|
71 |
+
if xx + w2 * self.pow2[abs(hi-center[1])] <= r:
|
72 |
+
poly.add((wi, hi))
|
73 |
+
self.components.append(poly)
|
74 |
+
return poly
|
75 |
+
def rotate_component(comp, radian):
|
76 |
+
retv = set()
|
77 |
+
return retv
|
78 |
+
def save(self):
|
79 |
+
Image.fromarray(self.img1).filter(filter=ImageFilter.GaussianBlur(random.randint(0, 1))).save(self.file_name)
|
80 |
+
Image.fromarray(self.img2).save(self.depth_name)
|
81 |
+
with open(self.tags_name, "w") as file:
|
82 |
+
if self.layer_max is None:
|
83 |
+
file.write("")
|
84 |
+
else:
|
85 |
+
file.write(f"{self.layer_max+1}depth")
|
86 |
+
|
87 |
+
|
88 |
+
import uuid
|
89 |
+
import concurrent.futures
|
90 |
+
from tqdm import tqdm
|
91 |
+
import os
|
92 |
+
|
93 |
+
def process_polygon():
|
94 |
+
random_uuid = str(uuid.uuid4())
|
95 |
+
polygon = SimplePolygon(f"data/{random_uuid}.png", f"label/{random_uuid}.png", f"data/{random_uuid}.txt")
|
96 |
+
for _ in range(random.randint(4, 10)):
|
97 |
+
if random.randint(0,1)==0:
|
98 |
+
polygon.add_ellipse()
|
99 |
+
else:
|
100 |
+
polygon.add_rect()
|
101 |
+
polygon.generate()
|
102 |
+
polygon.save()
|
103 |
+
|
104 |
+
def main():
|
105 |
+
if not os.path.exists("data"):
|
106 |
+
os.makedirs("data")
|
107 |
+
if not os.path.exists("label"):
|
108 |
+
os.makedirs("label")
|
109 |
+
num_processes = 12
|
110 |
+
total_runs = 100000
|
111 |
+
|
112 |
+
with tqdm(total=total_runs, ncols=80) as pbar:
|
113 |
+
with concurrent.futures.ProcessPoolExecutor(max_workers=num_processes) as executor:
|
114 |
+
futures = [executor.submit(process_polygon) for _ in range(total_runs)]
|
115 |
+
for future in concurrent.futures.as_completed(futures):
|
116 |
+
pbar.update(1)
|
117 |
+
|
118 |
+
if __name__ == "__main__":
|
119 |
+
main()
|
label.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:092fdbfed30fc966b07739ad3f87646a58a018d9112e1675e066cbc269b83d93
|
3 |
+
size 298943046
|
readme.md
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
|
4 |
+
# depth(?) overlap TrainData
|
5 |
+
|
6 |
+
Approximately 100,000 images
|
7 |
+
|
8 |
+
## example 1
|
9 |
+
|
10 |
+
![example 1 train](sample/000adad0-657b-4ce4-93d2-159f3ca80798.png)
|
11 |
+
|
12 |
+
|
13 |
+
![example 1 label](sample/000adad0-657b-4ce4-93d2-159f3ca80798-label.png)
|
14 |
+
|
15 |
+
## example 2
|
16 |
+
|
17 |
+
![example 2 train](sample/0000c1cd-30d9-42e8-82ae-9109ca6be939.png)
|
18 |
+
|
19 |
+
|
20 |
+
![example 2 label](sample/0000c1cd-30d9-42e8-82ae-9109ca6be939-label.png)
|
21 |
+
|
sample/0000c1cd-30d9-42e8-82ae-9109ca6be939-label.png
ADDED
Git LFS Details
|
sample/0000c1cd-30d9-42e8-82ae-9109ca6be939.png
ADDED
Git LFS Details
|
sample/0000c1cd-30d9-42e8-82ae-9109ca6be939.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
5depth
|
sample/000adad0-657b-4ce4-93d2-159f3ca80798-label.png
ADDED
Git LFS Details
|
sample/000adad0-657b-4ce4-93d2-159f3ca80798.png
ADDED
Git LFS Details
|
sample/000adad0-657b-4ce4-93d2-159f3ca80798.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
5depth
|