Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenVQA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vision
GenVQA
Commits
784ac86c
There was an error fetching the commit references. Please try again later.
Commit
784ac86c
authored
9 years ago
by
Kevin Shih
Browse files
Options
Downloads
Patches
Plain Diff
perturbing shape sizes and shape colors to increase difficulty
parent
a5fdc5d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shapes_dataset/gen_dataset.py
+21
-8
21 additions, 8 deletions
shapes_dataset/gen_dataset.py
with
21 additions
and
8 deletions
shapes_dataset/gen_dataset.py
+
21
−
8
View file @
784ac86c
...
@@ -4,7 +4,7 @@ import sys
...
@@ -4,7 +4,7 @@ import sys
import
os
import
os
import
json
import
json
import
random
import
random
from
PIL
import
Image
,
ImageDraw
from
PIL
import
Image
,
ImageDraw
,
ImageColor
from
shape_globals
import
Globals
from
shape_globals
import
Globals
SHAPES
=
Globals
.
SHAPES
SHAPES
=
Globals
.
SHAPES
...
@@ -33,17 +33,30 @@ def gen_image(block_array):
...
@@ -33,17 +33,30 @@ def gen_image(block_array):
cnt
=
0
;
cnt
=
0
;
for
blk
in
block_array
:
for
blk
in
block_array
:
x1
=
(
cnt
%
3
)
*
100
+
1
+
eps
x1
=
(
cnt
%
3
)
*
100
+
1
+
eps
x2
=
x1
+
100
-
2
*
eps
x2
=
x1
+
100
-
2
*
eps
y1
=
cnt
/
3
*
100
+
eps
y1
=
cnt
/
3
*
100
+
eps
y2
=
y1
+
100
-
2
*
eps
y2
=
y1
+
100
-
2
*
eps
x1
+=
random
.
randint
(
0
,
15
)
x2
-=
random
.
randint
(
0
,
15
)
y1
+=
random
.
randint
(
0
,
15
)
y2
-=
random
.
randint
(
0
,
15
)
if
blk
.
shape
>
0
:
if
blk
.
shape
>
0
:
c1
=
255
-
random
.
randint
(
0
,
50
)
c2
=
random
.
randint
(
0
,
70
)
c3
=
random
.
randint
(
0
,
70
)
if
blk
.
color
==
0
:
col
=
'
rgb(%d, %d, %d)
'
%
(
c1
,
c2
,
c3
)
elif
blk
.
color
==
1
:
col
=
'
rgb(%d, %d, %d)
'
%
(
c2
,
c1
,
c3
)
elif
blk
.
color
==
2
:
col
=
'
rgb(%d, %d, %d)
'
%
(
c2
,
c3
,
c1
)
if
blk
.
shape
==
1
:
# square
if
blk
.
shape
==
1
:
# square
draw
.
rectangle
((
x1
,
y1
,
x2
,
y2
),
fill
=
COLORS
[
blk
.
color
]
,
outline
=
'
black
'
)
draw
.
rectangle
((
x1
,
y1
,
x2
,
y2
),
fill
=
col
,
outline
=
'
black
'
)
elif
blk
.
shape
==
2
:
elif
blk
.
shape
==
2
:
draw
.
polygon
((
x1
,
y1
,
x2
,
y1
,
(
x1
+
x2
)
/
2
,
y2
),
fill
=
COLORS
[
blk
.
color
]
,
outline
=
'
black
'
)
draw
.
polygon
((
x1
,
y1
,
x2
,
y1
,
(
x1
+
x2
)
/
2
,
y2
),
fill
=
col
,
outline
=
'
black
'
)
else
:
else
:
draw
.
ellipse
((
x1
,
y1
,
x2
,
y2
),
fill
=
COLORS
[
blk
.
color
]
,
outline
=
'
black
'
)
draw
.
ellipse
((
x1
,
y1
,
x2
,
y2
),
fill
=
col
,
outline
=
'
black
'
)
#else: # diamond
#else: # diamond
#draw.polygon((x1,(y1+y2)/2, (x1+x2)/2, y1, x2, (y1+y2)/2, (x1+x2)/2, y2), fill = COLORS[blk.color], outline = 'black')
#draw.polygon((x1,(y1+y2)/2, (x1+x2)/2, y1, x2, (y1+y2)/2, (x1+x2)/2, y2), fill = COLORS[blk.color], outline = 'black')
cnt
=
cnt
+
1
cnt
=
cnt
+
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment