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

Testing MapReader #2

Closed
11 tasks done
ChristinaLast opened this issue Nov 23, 2021 · 18 comments
Closed
11 tasks done

Testing MapReader #2

ChristinaLast opened this issue Nov 23, 2021 · 18 comments
Assignees

Comments

@ChristinaLast
Copy link
Collaborator

ChristinaLast commented Nov 23, 2021

Hi All 👋🏼

I will be testing MapReader install and the demo notebooks run to evecute the analysis. I will document my process here

  • Installation
    • Install git clone git@github.com:Living-with-machines/MapReader.git
    • git branch -> * dev
    • git pull origin dev
    • poetry install
    • poetry shell
      • this command was not included in the README.md (unlike conda activate ...)
  • Notebooks code execution
    • 001_retrieve_patchify_plot.ipynb
    • 002_annotation.ipynb
    • 003_train_classifier.ipynb
    • 004_inference.ipynb
@kasra-hosseini
Copy link
Member

@ChristinaLast This is great! Many thanks for that.

@kasra-hosseini kasra-hosseini added this to Backlog in Project board via automation Nov 23, 2021
@kasra-hosseini kasra-hosseini moved this from Backlog to In progress in Project board Nov 23, 2021
@kasra-hosseini
Copy link
Member

@ChristinaLast All the notebooks are now on the repo. Please let us know when you are done with your tests. (Note that I also updated the poetry lock file).

@kasra-hosseini
Copy link
Member

We will release v0.1.0 if you could successfully (and easily) install and run all the notebooks.

@ChristinaLast
Copy link
Collaborator Author

Can definitely take a look this afternoon! Excited! 😇

@kasra-hosseini
Copy link
Member

Thanks :)

@ChristinaLast
Copy link
Collaborator Author

Would you be able to add me as a contributor so I can suggest changes on a branch?

@kasra-hosseini
Copy link
Member

Done

@ChristinaLast
Copy link
Collaborator Author

Plotting annotations
annotated_images.show_image_labels(tar_label=1, num_sample=6) # works for <=2

When plotting the annotations I am recieving this error
FileNotFoundError: No such file:
full traceback:

FileNotFoundError                         Traceback (most recent call last)
/var/folders/p2/kyb6y_1d0pv_vvpdvlcz39h40000gr/T/ipykernel_468/2944304206.py in <module>
      1 # show sample images for target label (tar_label)
----> 2 annotated_images.show_image_labels(tar_label=1, num_sample=6)

~/Documents/2021_projects/LwM/MapReader/mapreader/annotate/load_annotate.py in show_image_labels(self, tar_label, num_sample)
    241         for indx in range(num_sample):
    242             plt.subplot(int(num_sample/2.), 3, indx+1)
--> 243             plt.imshow(io.imread(annot2plot.iloc[indx][self.col_path]))
    244             plt.xticks([])
    245             plt.yticks([])

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
     46 
     47     with file_or_url_context(fname) as fname:
---> 48         img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
     49 
     50     if not hasattr(img, 'ndim'):

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
    205                                (plugin, kind))
    206 
--> 207     return func(*args, **kwargs)
    208 
    209 

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/skimage/io/_plugins/imageio_plugin.py in imread(*args, **kwargs)
      8 @wraps(imageio_imread)
      9 def imread(*args, **kwargs):
---> 10     return np.asarray(imageio_imread(*args, **kwargs))

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/imageio/core/functions.py in imread(uri, format, **kwargs)
    157         )
    158 
--> 159     with imopen(uri, "ri", plugin=format) as file:
    160         return file.read(index=0, **kwargs)
    161 

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/imageio/core/imopen.py in imopen(uri, io_mode, plugin, legacy_mode, **kwargs)
    135         io_mode = request.mode.io_mode
    136     else:
--> 137         request = Request(uri, io_mode)
    138 
    139     # plugin specified, no search needed

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/imageio/core/request.py in __init__(self, uri, mode, **kwargs)
    243 
    244         # Parse what was given
--> 245         self._parse_uri(uri)
    246 
    247         # Set extension

~/Documents/2021_projects/LwM/MapReader/.venv/lib/python3.8/site-packages/imageio/core/request.py in _parse_uri(self, uri)
    381                 # Reading: check that the file exists (but is allowed a dir)
    382                 if not os.path.exists(fn):
--> 383                     raise FileNotFoundError("No such file: '%s'" % fn)
    384             else:
    385                 # Writing: check that the directory to write to does exist

FileNotFoundError: No such file: '/Users/clast/Documents/2021_projects/LwM/MapReader/examples/classification_one_inch_maps_001/maps_tutorial/slice_50_50/patch-4500-950-4550-1000-#map_101168618.png#.PNG'

@kasra-hosseini
Copy link
Member

Could you please check if you have this file locally:

maps_tutorial/slice_50_50/patch-4500-950-4550-1000-#map_101168618.png#.PNG

@kasra-hosseini kasra-hosseini changed the title Testing MapReader for first release Testing MapReader Nov 30, 2021
@kasra-hosseini kasra-hosseini mentioned this issue Nov 30, 2021
@ChristinaLast
Copy link
Collaborator Author

I didnt forget about this - but dont have this file:/ closest it has generated is:

find . -type f -iname "patch-4500-950-4550-1000*"
./patch-4500-950-4550-1000-#map_101168609.png#.PNG
./patch-4500-950-4550-1000-#map_101167745.png#.PNG
./patch-4500-950-4550-1000-#map_101168702.png#.PNG
./patch-4500-950-4550-1000-#map_101168036.png#.PNG

@kasra-hosseini
Copy link
Member

OK, I see. In our tutorials, we use the following lines to find and retrieve maps:

tileserver.query_point([51.53, -0.12])
# # if append = False, only the last query will be stored
tileserver.query_point([51.4, 0.08], append=True)
tileserver.query_point([51.4, -0.13], append=True)
tileserver.query_point([51.52, 0.03], append=True)

I assume you used different query points? Could you check this, please?

If you use the above commands, the following maps will be stored locally:

maps_tutorial
├── map_101168609.png
├── map_101168618.png
├── map_101168702.png
├── map_101168708.png
└── metadata.csv

and after patchifying, you will have patch-4500-950-4550-1000-#map_101168618.png#.PNG (I hope :) ).

(Note that #map_101168618.png# in the file name refers to the parent/original map.)

@kasra-hosseini
Copy link
Member

I hope this solves the issue; however, I think we need a function in the loadAnnotations class to check the consistency between the read annotations and available patches (to avoid future issues like this). I will open a ticket for this.

@ChristinaLast
Copy link
Collaborator Author

ChristinaLast commented Dec 1, 2021

Yes, I have changed these to:

tileserver.query_point([51.53, -0.12])
# # if append = False, only the last query will be stored
tileserver.query_point([52.4033848, -1.534723], append=True)
tileserver.query_point([51.5956638, -0.0650902], append=True)
tileserver.query_point([51.4833289, -0.1081195], append=True)
tileserver.query_point([52.9449011, -1.2420748], append=True)

when printing these queries using:
tileserver.print_found_queries()

I get:

------------
Found items:
------------
URL:     	https://maps.nls.uk/view/101168609
filepath:	map_101168609.png
coords:  	[-4.06538210e-01  2.07213000e-02  5.15026204e+01  5.16848974e+01]
index:   	378
====================
URL:     	https://maps.nls.uk/view/101168036
filepath:	map_101168036.png
coords:  	[-1.6382443  -1.20698142 52.39222153 52.57026517]
index:   	294
====================
URL:     	https://maps.nls.uk/view/101168702
filepath:	map_101168702.png
coords:  	[-4.15144570e-01  1.04388000e-02  5.13292371e+01  5.15114618e+01]
index:   	390
====================
URL:     	https://maps.nls.uk/view/101167745
filepath:	map_101167745.png
coords:  	[-1.62575507 -1.18923268 52.91266376 53.09077452]
index:   	250
====================

I am not sure why it is trying to pull map_101168618 when this is not part of the maps I am querying.

@ChristinaLast
Copy link
Collaborator Author

Rerunning the notebooks results in a similar error:
FileNotFoundError: No such file: '/Users/clast/Documents/2021_projects/LwM/MapReader/examples/classification_one_inch_maps_001/maps_tutorial/slice_50_50/patch-3750-2250-3800-2300-#map_101168618.png#.PNG

A different patch label, but the same non-existent map label, (map_101168618).

@kasra-hosseini
Copy link
Member

In 003_train_classifier.ipynb, are you running:

annotated_images.load("./annotations_one_inch/rail_space_#kasra#.csv", 
                      path2dir="./maps_tutorial/slice_50_50")

rail_space_#kasra#.csv is a file that I created for the tutorials in which we have annotated that patch (i.e., patch-3750-2250-3800-2300-#map_101168618.png#.PNG), see: https://github.com/Living-with-machines/MapReader/blob/main/examples/classification_one_inch_maps_001/annotations_one_inch/rail_space_%23kasra%23.csv#L180

It seems to me that there is an inconsistency between the annotation file, i.e., ./annotations_one_inch/rail_space_#kasra#.csv and your queried maps. You can either use your own annotation files (the ones that you create here: #9) or query/patchify these maps (following the tutorial) as rail_space_#kasra#.csv contains annotations for these maps

tileserver.query_point([51.53, -0.12])
# # if append = False, only the last query will be stored
tileserver.query_point([51.4, 0.08], append=True)
tileserver.query_point([51.4, -0.13], append=True)
tileserver.query_point([51.52, 0.03], append=True)

Can you also take a look at this issue: #7. I think this is a very important one that needs to be addressed soon. (I will work on it this week).

@ChristinaLast
Copy link
Collaborator Author

ok, when using my own annotations it works, I think I am understanding a little more about how the package works!
Should I add a little 🚨🚨 WARNING: 🚨🚨 that if a user changes the locations for the map retrieval, they will need to develop and use their own annotation csv?

Im not sure if one of your patches already acheives this though! 🙈

I am taking a look at #7 now!

@kasra-hosseini
Copy link
Member

@ChristinaLast Thanks. It would be great if you add 🚨🚨 . I will also add new functionality this week to check the consistency (i.e., overlap) between the annotation list and sliced images.

@kasra-hosseini
Copy link
Member

@ChristinaLast Thank you again for the tests. I close this issue now.

Project board automation moved this from In progress to Done Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants