TonyXuQAQ / Topo-boundary

A public available dataset for road boundary detection in aerial images
GNU General Public License v3.0
110 stars 19 forks source link

Using own data #25

Open christophTUM opened 1 year ago

christophTUM commented 1 year ago

Hello,

i am a bit confused about how to use own aerial images. If i save the images in my manual created cropped_tiff folder, and running e.g. init_vertex i get this error message:

Traceback (most recent call last):
  File "utils/init_vertex_extraction.py", line 38, in <module>
    image_list = os.listdir(image_dir)
FileNotFoundError: [Errno 2] No such file or directory: './records/endpoint/test'
cp: cannot stat './records/endpoint/vertices/*': No such file or directory

I created the docker image and i am inside the container by running ./build_container.bash inside the subdirectory of init_vertex.

TonyXuQAQ commented 1 year ago

Thanks for the questions.

In short, the answer is that you did not provide the model with initial vertices to start the iteration. You can either:

(1) If you have the ground-truth graph label of your aerial images: Please follow Enhanced-iCurb and make sure your data has the same data structure as ours. And the ground-truth endpoints of the graph label will be used as initial vertices.

(2) If you do not have the ground-truth graph label of your aerial images: Please follow init_vertex. You can generate predicted initial vertices by following the steps of this README. Predicted initial vertices will be saved in ./records/endpoint/vertices. You can also manually annotate initial vertices manually and put the annotated initial vertices coordinates into ./records/endpoint/vertices (make sure the data structure is consistent).

By the way, due to the resolution, image quality, city styles, and so on, we do not promise that provided checkpoints can produce satisfactory results for your own data. Re-train all models is the best option for a customized dataset.

christophTUM commented 1 year ago

Thanks for the fast reply. I created 2 .jp2 files and converted them to tiff with the provided script. For that i modified the data_split.json file accordingly. However, if i start the init_vertex ./run_eval.bash script this error occurs:

Traceback (most recent call last):
  File "eval.py", line 18, in <module>
    from tensorboardX import SummaryWriter
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/__init__.py", line 5, in <module>
    from .torchvis import TorchVis
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/torchvis.py", line 10, in <module>
    from .writer import SummaryWriter
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/writer.py", line 16, in <module>
    from .comet_utils import CometLogger
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/comet_utils.py", line 7, in <module>
    from .summary import _clean_tag
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/summary.py", line 12, in <module>
    from .proto.summary_pb2 import Summary
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/proto/summary_pb2.py", line 16, in <module>
    from tensorboardX.proto import tensor_pb2 as tensorboardX_dot_proto_dot_tensor__pb2
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/proto/tensor_pb2.py", line 16, in <module>
    from tensorboardX.proto import resource_handle_pb2 as tensorboardX_dot_proto_dot_resource__handle__pb2
  File "/opt/conda/lib/python3.8/site-packages/tensorboardX/proto/resource_handle_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/opt/conda/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 561, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
0img [00:00, ?img/s]

I made sure to use a version of protobuf (protoc) which is higher than 3.19. Currently inside the docker 4.22.3 is installed.

TonyXuQAQ commented 1 year ago

Maybe try to comment/delete corresponding lines related to tensorboardX. It is not used in inference. It is not common to see env errors in docker.

christophTUM commented 1 year ago

I could successfully run init_vertex now, thank you. I had to fix some lines regarding the label loading.

However if i want to run iCurb i face the same problem with having no labels. I guess the labels are the vertices generated before?

=============
Successfully loading iCurb checkpoints!
=============
Pretrained FPN encoder checkpoint loaded!
Traceback (most recent call last):
  File "main.py", line 46, in <module>
    main()
  File "main.py", line 27, in main
    run_val(env,0)
  File "/topoBoundary/main_val.py", line 80, in run_val
    for i, data in enumerate(network.dataloader_valid):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/topoBoundary/utils/dataset.py", line 38, in __getitem__
    seq, seq_lens, init_points, end_points = load_seq(self.seq_list[idx])
  File "/topoBoundary/utils/dataset.py", line 94, in load_seq
    with open(seq_path) as json_file:
FileNotFoundError: [Errno 2] No such file or directory: './dataset/labels/dense_seq/test_1_00.json'

If I create this folder and put the vertices inside i dont get this error, but this instead:

Traceback (most recent call last):
  File "main.py", line 46, in <module>
    main()
  File "main.py", line 27, in main
    run_val(env,0)
  File "/topoBoundary/main_val.py", line 80, in run_val
    for i, data in enumerate(network.dataloader_valid):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/topoBoundary/utils/dataset.py", line 38, in __getitem__
    seq, seq_lens, init_points, end_points = load_seq(self.seq_list[idx])
  File "/topoBoundary/utils/dataset.py", line 105, in load_seq
    seq_lens.append(len(area['seq']))
TypeError: list indices must be integers or slices, not str

If i output area from the .json file i get this for my first value: [595, 986]. It seems like some informations inside the file are missing.

TonyXuQAQ commented 1 year ago

I see. In our origin code, we load all the ground-truth labels both in the training and inference phases, you could ignore those lines and comment/delete them. We did not consider adapting our code for other customized datasets. Sorry for the caused inconvenience.

You could actually modify the code to avoid loading some innecessary data or labels if any similar bugs are met.