Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowing for non-command line use #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/python
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
15 changes: 14 additions & 1 deletion scripts/retrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ def main(_):
f.write('\n'.join(image_lists.keys()) + '\n')


if __name__ == '__main__':
def init_parser():
parser = argparse.ArgumentParser()
parser.add_argument(
'--image_dir',
Expand Down Expand Up @@ -1322,5 +1322,18 @@ def main(_):
takes 128x128 images. See https://research.googleblog.com/2017/06/mobilenets-open-source-models-for.html
for more information on Mobilenet.\
""")
return parser


def run_with_args(**kwargs):
exec_args = sum([['--' + k, str(v)] for k, v in kwargs.items()], [])
parser = init_parser()
global FLAGS
FLAGS = parser.parse_args(exec_args)
main(None)


if __name__ == '__main__':
parser = init_parser()
FLAGS, unparsed = parser.parse_known_args()
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)