Skip to content

Commit

Permalink
Updating evaluation function
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinTeichmann committed Jan 20, 2017
1 parent 0c07c0f commit 026e273
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _progress(count, block_size, total_size):
filepath, _ = urllib.request.urlretrieve(url, filepath,
reporthook=_progress)
print()
return filepath


def main():
Expand Down
31 changes: 27 additions & 4 deletions evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def dict_merge(dct, merge_dct):
import tensorvision.analyze as ana
import tensorvision.utils as utils

flags.DEFINE_string('RUN', 'KittiSeg_trained',
flags.DEFINE_string('RUN', 'KittiSeg_pretrained',
'Modifier for model parameters.')
flags.DEFINE_string('hypes', 'hypes/KittiSeg.json',
'File storing model parameters.')
Expand All @@ -76,7 +76,25 @@ def dict_merge(dct, merge_dct):
'hence it will get overwritten by further runs.'))


def maybe_download_and_extract():
segmentation_weights_url = ("ftp://mi.eng.cam.ac.uk/"
"pub/mttt2/models/KittiSeg_pretrained.zip")


def maybe_download_and_extract(runs_dir):
logdir = os.path.join(runs_dir, FLAGS.RUN)

if os.path.exists(logdir):
# weights are downloaded. Nothing to do
return

if not FLAGS.RUN == 'KittiSeg_pretrained':
return

import zipfile
download_name = utils.download(segmentation_weights_url, runs_dir)

zipfile.ZipFile(download_name, 'r').extractall(runs_dir)

return


Expand All @@ -97,7 +115,7 @@ def main(_):
hypes = json.load(f)
utils.load_plugins()

if False and 'TV_DIR_RUNS' in os.environ:
if 'TV_DIR_RUNS' in os.environ:
runs_dir = os.path.join(os.environ['TV_DIR_RUNS'],
'KittiSeg')
else:
Expand All @@ -109,11 +127,16 @@ def main(_):

train.maybe_download_and_extract(hypes)

maybe_download_and_extract()
maybe_download_and_extract(runs_dir)
logging.info("Start Analysis")
logdir = os.path.join(runs_dir, FLAGS.RUN)
ana.do_analyze(logdir)

logging.info("Analysis for pretrained model complete.")
logging.info("For evaluating your own models I recommend using:"
"`tv-analyze --logdir /path/to/run`.")
logging.info("tv-analysis has a much cleaner interface.")


if __name__ == '__main__':
tf.app.run()
2 changes: 1 addition & 1 deletion submodules/TensorVision

0 comments on commit 026e273

Please sign in to comment.