Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 6f95d6a2 authored by tekin_g's avatar tekin_g
Browse files

improve synthetic data generation

parent d785bb59
No related branches found
No related tags found
No related merge requests found
...@@ -21,11 +21,12 @@ generation_number = 100 # number of files to output ...@@ -21,11 +21,12 @@ generation_number = 100 # number of files to output
line_thickness = (4,15)*255 line_thickness = (4,15)*255
line_color = (0.6,0.98) line_color = (0.6,0.98)
background_color = (0.1,0.25)
line_count = 10 line_count = 10
square_count = 15 square_count = 15
circle_count = 15 circle_count = 15
random_noise = 0.2
blur_kernel = "custom" blur_kernel = "custom"
#Options for blur_kernel = "gaussian" #Options for blur_kernel = "gaussian"
...@@ -41,8 +42,9 @@ output_npz = True ...@@ -41,8 +42,9 @@ output_npz = True
output_single_npz = False # requires lots of memory output_single_npz = False # requires lots of memory
interactive = False interactive = False
def gen_image(height, width, thickness, color, line_count , square_count): def gen_image(height, width, b_color, thickness, color, line_count , square_count):
image = np.zeros((height, width), dtype=np.float32) b_color = random.uniform(b_color[0],b_color[1])
image = np.ones((height, width),dtype=np.float32)* b_color
for i in range(line_count): for i in range(line_count):
thickness_i = random.randint(thickness[0],thickness[1]) thickness_i = random.randint(thickness[0],thickness[1])
color_i = random.uniform(color[0],color[1]) color_i = random.uniform(color[0],color[1])
...@@ -92,8 +94,11 @@ if output_single_npz: ...@@ -92,8 +94,11 @@ if output_single_npz:
storage = np.zeros((2,generation_number,output_height,output_width),dtype=np.float64) storage = np.zeros((2,generation_number,output_height,output_width),dtype=np.float64)
for i in range(generation_number): for i in range(generation_number):
gt = gen_image(output_height, output_width, line_thickness, line_color, line_count,square_count) gt = gen_image(output_height, output_width, background_color,line_thickness, line_color, line_count,square_count)
gt = np.clip(gt,a_min=0,a_max=1)
blured = cv2.filter2D(gt, -1, kernel) blured = cv2.filter2D(gt, -1, kernel)
blured = blured + np.random.rand(blured.shape[0],blured.shape[1]) * random_noise
blured = np.clip(blured,a_min=0,a_max=1)
if interactive: if interactive:
show_image(gt, "gt") show_image(gt, "gt")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment