MarvinTeichmann / KittiSeg

A Kitti Road Segmentation model implemented in tensorflow.
MIT License
910 stars 403 forks source link

Segmentation of new data using pretrained network #40

Closed FredHaa closed 7 years ago

FredHaa commented 7 years ago

I have been using your framework to train networks for bacteria segmentation with great succes. However, now I would like to actually use the networks to segment new data, and I can't for the life of me figure out how.

I have installed the TensorVision backend, so I have access to tv-analyze etc.

When i run tv-analyze --logdir ~/KittiSeg/RUNS/run1/ i get the following error:

2017-04-19 09:48:42,689 INFO No environment variable 'TV_PLUGIN_DIR' found. Set to '/home/frederik/tv-plugins'.
2017-04-19 09:48:42,689 INFO No environment variable 'TV_STEP_SHOW' found. Set to '50'.
2017-04-19 09:48:42,689 INFO No environment variable 'TV_STEP_EVAL' found. Set to '250'.
2017-04-19 09:48:42,690 INFO No environment variable 'TV_STEP_WRITE' found. Set to '1000'.
2017-04-19 09:48:42,690 INFO No environment variable 'TV_MAX_KEEP' found. Set to '10'.
2017-04-19 09:48:42,690 INFO No environment variable 'TV_STEP_STR' found. Set to 'Step {step}/{total_steps}: loss = {loss_value:.2f}; lr = {lr_value:.2e}; {sec_per_batch:.3f} sec (per Batch); {examples_per_sec:.1f} imgs/sec'.
2017-04-19 09:48:42,690 INFO Starting to analyze model in '/home/frederik/Documents/Uni/semester_8/AI4/DeepBacteriaSegmentation/network/RUNS/KittiSeg-5000_2017_04_18_18.27'
2017-04-19 09:48:42,690 INFO f: <open file '/home/frederik/Documents/Uni/semester_8/AI4/DeepBacteriaSegmentation/network/RUNS/KittiSeg-5000_2017_04_18_18.27/model_files/hypes.json', mode 'r' at 0x7f6505edc810>
Traceback (most recent call last):
  File "./tv-analyze", line 4, in <module>
    __import__('pkg_resources').run_script('tensorvision==0.1.dev1', 'tv-analyze')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 738, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1499, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/tensorvision-0.1.dev1-py2.7.egg/EGG-INFO/scripts/tv-analyze", line 36, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/usr/local/lib/python2.7/dist-packages/tensorvision-0.1.dev1-py2.7.egg/tensorvision/analyze.py", line 476, in main
    do_analyze(FLAGS.logdir)
  File "/usr/local/lib/python2.7/dist-packages/tensorvision-0.1.dev1-py2.7.egg/tensorvision/analyze.py", line 62, in do_analyze
    modules = utils.load_modules_from_logdir(logdir)
  File "/usr/local/lib/python2.7/dist-packages/tensorvision-0.1.dev1-py2.7.egg/tensorvision/utils.py", line 215, in load_modules_from_logdir
    arch = imp.load_source("arch_%s" % postfix, f)
  File "/home/frederik/Documents/Uni/semester_8/AI4/DeepBacteriaSegmentation/network/RUNS/KittiSeg-5000_2017_04_18_18.27/model_files/architecture.py", line 15, in <module>
    from tensorflow_fcn import fcn8_vgg
ImportError: No module named tensorflow_fcn

Any idea how I get it to locate tensorflow_fcn?

Also, can I even use tv-analyze to segment new data, or is it only for evaluating the performance of a trained network?

MarvinTeichmann commented 7 years ago

Hi,

tv-analyze eventually runs the eval.py in the model_dir in the logdir folder. So if you adapt / change the file you can easily segment new data. Basically you need to delete all the confusion matrix code and just save the segmented images.

ImportError: No module named tensorflow_fcn

Make sure to set you path variabels correctly. There are many ways to set path. Inside the script (e.g. sys.path.append) or in bash. Try google or stackoverflow to learn how to adjust python pathes.