mitroadmaps / roadtracer

MIT License
235 stars 76 forks source link

Inference on new satellite imagery #31

Open ntelo007 opened 4 years ago

ntelo007 commented 4 years ago

Hi,

I am trying to use infer.py with a new satellite image that I obtained to get results from your trained model. Therefore, I would like to ask you which packages do I need to install to use your model?

I am using Windows 10. I noticed that you have some print statements without parenthesis, so I guess you use Python 2.7. I found out that TensorFlow is not supported on Windows with Python 2.7. Does that mean that I can't run your code?

If not, please provide some guidance.

uakfdotb commented 4 years ago

I don't know about TensorFlow on Windows, but yes it is Python 2.7 and need TensorFlow any version between 1.10 to 1.14 should be good (but not 2.0). Version for other packages shouldn't matter as much, if you get ImportError then you can install the package.

ntelo007 commented 4 years ago

I created a virtual machine running Ubuntu 18.04 and I am using the following command to get results from your trained model:

python infer.py /home/.../data/model/model out-ntelo.graph --t /home/.../data/imagery/image.tiff --g /home/.../data//graphs --j /home/.../data/json/ --r 'new york' --s 0.03 --f 0.75 

I receive the following error:

reading tiles
Traceback (most recent call last):
  File "infer.py", line 277, in <module>
    tiles = tileloader.Tiles(PATHS_PER_TILE_AXIS, SEGMENT_LENGTH, 16, TILE_MODE)
  File "/home/.../roadtracer-master/roadtracer/tileloader.py", line 149, in _init_
    self.all_tiles = get_tile_list()
  File "/home/.../roadtracer-master/roadtracer/tileloader.py", line 99, in get_tile_list
    with open(pytiles_path, 'r') as f:
IOError: [Errno 2] No such file or directory: '/home/.../roadtracer-master/data/json/pytiles.json'

I already changed the following part of the code inside infer.py:

USE_TL_LOCATIONS = False
MANUAL_POINT1 = geom.Point(101206, 869770)
MANUAL_POINT2 = geom.Point(101485, 869090)

The image that I want to use belongs to the Massachussets Road Detection Dataset and is the following: https://drive.google.com/file/d/10ZJH80b5UMSE8VNhb49mwFbgSWkRhFkd/view?usp=sharing

Can you please help me solve this issue and infer results?

ntelo007 commented 4 years ago

Using the following code:

python infer.py ~/.../roadtracer-master/data/model/model out.graph --t ~/.../roadtracer-master/data/imagery/ --g ~/.../roadtracer-master/data/graphs/ --j ~/.../roadtracer-master/data/json/

produces the following error:

IOError: [Errno 2] No such file or directory: '/.../roadtracer-master/data/graphs/chicago.graph'

I though that by specifying manual points, it wouldn't care about graph and json file. Can you please help me run infer.py for a new image, which I uploaded already in the previous comment?

devolfnn commented 4 years ago

Using the following code:

python infer.py ~/.../roadtracer-master/data/model/model out.graph --t ~/.../roadtracer-master/data/imagery/ --g ~/.../roadtracer-master/data/graphs/ --j ~/.../roadtracer-master/data/json/

produces the following error:

IOError: [Errno 2] No such file or directory: '/.../roadtracer-master/data/graphs/chicago.graph'

I though that by specifying manual points, it wouldn't care about graph and json file. Can you please help me run infer.py for a new image, which I uploaded already in the previous comment?

Hi, have you figured out how to inference on a custom image without graph? I did it this way:

  1. Initialize a graph with the following lines. W and H refers to the width and height of the image, MANUAL_POINT1 can be any points as it will not be used during inference, MANUAL_POINT2 is the actual starting point that will be used.

    TILE_START = geom.Point(0, 0)
    TILE_END = TILE_START.add(geom.Point(W, H))
    
    rect = geom.Rectangle(TILE_START, TILE_END)
    start_loc = [{
        'point':MANUAL_POINT1,
        'edge_pos':None,
    },{
        'point':MANUAL_POINT2,
        'edge_pos':None
    }]
    tile_data = {
        'region': REGION,
        'rect': rect,
        'search_rect': rect.add_tol(-WINDOW_SIZE/2),
        'cache': None,
        'starting_locations': [start_loc],
    }
  2. Use the function "make_path_input" to draw path already generated on the cropped image patch.

  3. Forward the model with following lines:

        batch_angle_outputs, batch_stop_outputs, batch_detect_outputs = \
            session.run([m.angle_outputs, m.action_outputs, m.detect_outputs], feed_dict=feed_dict)
        batch_angle_outputs, batch_stop_outputs = fix_outputs(batch_angle_outputs, batch_stop_outputs)
  4. Insert newly generated vertex into the graph.

My infer codes are modified based on the infer.py script, it generates slightly different results compared with the infer.py script, and sometimes, inference quality rely on the location where it starts tracing.