-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Loïc Vanden Bemden
committed
Jan 27, 2020
1 parent
6501d09
commit fe0ce3d
Showing
58 changed files
with
1,795 additions
and
1,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
example/test-run.player.json → ...utput-examples/example-detect.player.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"clean_top": true, | ||
"food_size": 5, | ||
"food_size": 6, | ||
"use_food_circle": true | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"clean_top": false, | ||
"food_size": 6, | ||
"use_food_circle": true | ||
} |
32 changes: 32 additions & 0 deletions
32
data/output-examples/simulation/100_loops/100_loops.blob.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"Computing": { | ||
"Blob Size Factor": 0.25, | ||
"Covering Factor": 0.75, | ||
"Global Factor": 2.78, | ||
"Known Foods Factor": 0.05 | ||
}, | ||
"Gathering": { | ||
"Diagonal Moves": true, | ||
"Light Compute": true, | ||
"Sightline": -1 | ||
}, | ||
"Global Decrease": 0.1, | ||
"Harvesting": { | ||
"Collect": 10, | ||
"Eat": 5, | ||
"Max": 30, | ||
"Min": 30 | ||
}, | ||
"Remaining Blob on Food": 50, | ||
"Scouters": { | ||
"Drop by eat": 25, | ||
"Min": 2 | ||
}, | ||
"Scouting": { | ||
"Diagonal Moves": true, | ||
"Global Explore Probability": 0.02, | ||
"Light Compute": true, | ||
"Search Locally on Food": true, | ||
"Sightline": 3 | ||
} | ||
} |
161 changes: 161 additions & 0 deletions
161
data/output-examples/simulation/100_loops/100_loops.board
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
example/test.player.json → ...imulation/100_loops/100_loops.player.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"clean_top": true, | ||
"food_size": 5, | ||
"food_size": 6, | ||
"use_food_circle": true | ||
} |
10 changes: 10 additions & 0 deletions
10
data/output-examples/simulation/100_loops/100_loops.results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Covering": { | ||
"Bottom": 34.74375, | ||
"Top": 9.35, | ||
"Total": 22.046875 | ||
}, | ||
"From": "save/example-detect", | ||
"Loops": 100, | ||
"To": "save/2019-06-07_16.26.50" | ||
} |
32 changes: 32 additions & 0 deletions
32
data/output-examples/simulation/10_loops/10_loops.blob.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"Computing": { | ||
"Blob Size Factor": 0.25, | ||
"Covering Factor": 0.75, | ||
"Global Factor": 2.78, | ||
"Known Foods Factor": 0.05 | ||
}, | ||
"Gathering": { | ||
"Diagonal Moves": true, | ||
"Light Compute": true, | ||
"Sightline": -1 | ||
}, | ||
"Global Decrease": 0.1, | ||
"Harvesting": { | ||
"Collect": 10, | ||
"Eat": 5, | ||
"Max": 30, | ||
"Min": 30 | ||
}, | ||
"Remaining Blob on Food": 50, | ||
"Scouters": { | ||
"Drop by eat": 25, | ||
"Min": 2 | ||
}, | ||
"Scouting": { | ||
"Diagonal Moves": true, | ||
"Global Explore Probability": 0.02, | ||
"Light Compute": true, | ||
"Search Locally on Food": true, | ||
"Sightline": 3 | ||
} | ||
} |
161 changes: 161 additions & 0 deletions
161
data/output-examples/simulation/10_loops/10_loops.board
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
data/output-examples/simulation/10_loops/10_loops.player.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"clean_top": true, | ||
"food_size": 6, | ||
"use_food_circle": true | ||
} |
10 changes: 10 additions & 0 deletions
10
data/output-examples/simulation/10_loops/10_loops.results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Covering": { | ||
"Bottom": 33.6875, | ||
"Top": 6.809375000000001, | ||
"Total": 20.2484375 | ||
}, | ||
"From": "save/example-detect", | ||
"Loops": 10, | ||
"To": "save/10_loops" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Width": 100, | ||
"Height": 40, | ||
"Foods": [ | ||
[10, 10], | ||
[18,28], | ||
[23, 8], | ||
[44,23], | ||
[96,22] | ||
], | ||
"Clean Top": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (C) 2019 - UMons | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
import argparse | ||
import json | ||
from detection.detection import detect, discretize, print_results | ||
from detection.refine import simulate, save | ||
from os.path import splitext, basename, join | ||
|
||
|
||
def main(): | ||
ap = argparse.ArgumentParser() | ||
ap.add_argument("-i", "--input", required=True, help="Uses this input as image for detection") | ||
ap.add_argument("-s", "--scale", type=float, default=0.10, help="Scales images by this factor (default: x0.1)") | ||
ap.add_argument("-c", "--config", type=str, default="detection/config.json", | ||
help="Loads config from this file (default: detection/config.json)") | ||
ap.add_argument("--save", type=str, default="save/", | ||
help="Pass the directory where saves are stored. (default: save/)") | ||
ap.add_argument("--hide", action='store_true', default=False, help="Hide images if parameter is set") | ||
ap.add_argument("--refine", type=str, help="Pass a json file to refine model") | ||
|
||
args = ap.parse_args() | ||
with open(args.config, 'r') as file: | ||
config = json.load(file) | ||
|
||
if args.refine is not None: | ||
with open(args.refine, 'r') as file: | ||
refine = json.load(file) | ||
else: | ||
refine = None | ||
|
||
orig, blob_mask, blob, food_mask, food_img = detect(args.input, config) | ||
dsc_img, dsc_blob, dsc_food_list = discretize(blob, food_mask, config['Discrete Width'], config['Discrete Height']) | ||
|
||
if args.save is not None: | ||
filename = splitext(basename(args.input))[0] + "-detect" | ||
file_path = join(args.save, filename) | ||
|
||
board, player, img = simulate(dsc_img, dsc_blob, dsc_food_list, config, refine) | ||
save(file_path, board, player, img) | ||
|
||
# Prepare file_path for details if any to save | ||
file_path += "-details" | ||
else: | ||
file_path = None | ||
|
||
print_results(orig, blob_mask, blob, food_mask, food_img, dsc_img, args.scale, file_path, args.hide) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
{ | ||
"Aspect Ratio": 0.4, | ||
"Discrete Height": 240, | ||
"Discrete Width": 600, | ||
"Discrete Height": 160, | ||
"Discrete Width": 400, | ||
"High Food Color": [ | ||
214, | ||
230, | ||
237 | ||
], | ||
"Limits": [ | ||
[136, 268], | ||
[5484, 208], | ||
[5452, 3296], | ||
[136, 3308] | ||
], | ||
[ | ||
136, | ||
268 | ||
], | ||
[ | ||
5484, | ||
208 | ||
], | ||
[ | ||
5452, | ||
3296 | ||
], | ||
[ | ||
136, | ||
3308 | ||
] | ||
], | ||
"Low Food Color": [ | ||
150, | ||
185, | ||
198 | ||
], | ||
"Min Food Size": 60 | ||
"Min Food Size": 60 | ||
} |
Oops, something went wrong.