Closed ambarja closed 1 year ago
@ambarja The location parameter you are passing is incorrect geographically and not in the right order! your latitude should be positive (12.117778919,12.116177610) and your coordinates should be passed in"lat ,lon, lat, lon" order. The location you entered is not valid [for the region shown by your coordinates], that is why the tool cannot build the correct grid to pair your tiles with it.
We highly recommend reading the two preparation guides carefully and if you are unsure, always check your coordinates with google maps to make sure you are passing the correct values.
@Mary-h86 I have just put the coordinates according google maps, but I have the same problem. We have negative coordinates for Peru. How would I deal with that?
@ambarja
The problems lies in the mismatch between your tile and the location you are passing. Negative coordinates aren't inherently problematic, but the issue seems to stem from incorrect tile coordinates. My comment was based on the tile numbers in your screen shot. I checked out those tile numbers, and here's what I found:
from tile2net.raster.tile_utils.genutils import num2deg
num2deg(299945,488726, 20)
This gives us:
(12.117879519823527, -77.02205657958984)
Looks like those aren't the right coordinates for your area. I think something went wrong when you were tiling.
Did you project your images to 4326 first before tiling?
And what's QGIS showing for the extent when you're setting up the tiles?
@Mary-h86 sorry, but I have generated my tiles using QGIS and boundary box I have taken from the qgis tool itself, as shown in the screenshot.
I hereby attach the image used. 👇
from tile2net import Raster
location = '-12.11760696,-77.02180781,-12.11635790,-77.02005634'
raster = Raster(
location=location,
name='lima_test',
input_dir='/content/drive/MyDrive/AntonyBarja/2023/Tile2Net/20/x_y_z.png',
output_dir = './lima-2/test',
zoom = 20
)
raster
lima_test Data Constructor.
Coordinate reference system (CRS): 4326
Tile size (pixel): 256
Zoom level: 20
Number of columns: 6
Number of rows: 5
Total tiles: 30
Number of tiles inside the boundary: 30 (100.0%)
raster.generate(2)
INFO Stitching Tiles...
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
[<ipython-input-44-50202d668e3f>](https://localhost:8080/#) in <cell line: 2>()
1 # Selección del stitch_step para la segmentación de imagenes
----> 2 raster.generate(2)
2 frames
[/content/tile2net/src/tile2net/raster/raster.py](https://localhost:8080/#) in stitch(self, step, force)
414 for file in itertools.chain.from_iterable(list_infiles)
415 ):
--> 416 raise FileNotFoundError(
417 f'No relevant tiles found in {self.project.tiles.static.path}. '
418 f'If multiple sources were matched, consider specifying a different source.'
FileNotFoundError: No relevant tiles found in /content/drive/MyDrive/AntonyBarja/2023/Tile2Net/20. If multiple sources were matched, consider specifying a different source.
@ambarja Thank you for providing the images. As we discussed yesterday, the problem is that your tile numbers (x,y) tiles do not match your location. The tile numbers shown in your screenshot correspond to a region in the opposite latitude (positive lat) compared to your region. The raster creates a grid based on the coordinates you passed, and it cannot locate the correct tiles to stitch since the numbers do not match.
Looking at your code, your input_dir argument does not seem to be correct, unless you changed the name and folder structure.
I created the tiles using QGIS: QGIS_Tiles and did the stitch, which works (stitched are also there)
Lets say you have the tiles saved in a folder called test (use the ones attached):
location = '-12.11760696,-77.02180781,-12.11635790,-77.02005634'
raster = Raster(
location=location,
name='lima_test',
input_dir='./test/20/x/y.png',
output_dir = './test',
zoom = 20
)
Now you can easily check what tile coordinates your Raster object expects:
raster.xtile
min xtile
299945
raster.xtilem
max xtile
299950
raster.ytile
max ytile
559849
raster.ytilem
min ytile
559845
So the ytiles (the name of your png files ) should be between 559845 and 559849, which based on your screenshot, they were not. One important point to note is the model is trained on the US cities where sidewalks generally have different materials compared to roads and the urban fabric is also different. The detection model unfortunately may not work as well in your region, which is something we cannot address at the moment but it is in our extend our training data to be more generalizable.
Good Luck!
@Mary-h86 First of all thank you very much for your support, I understand that the models were initially trained in the USA, therefore the results in other areas may not be as adequate. Is there a way to improve the model? And one last question when you generate the tiles in QGIS the structure you gave me is somewhat different from the ouput that usually comes out when you run the tool. What version of qgis do you recommend me to use?
Thank you very much for everything.
@ambarja Happy to help and glad to see that you are making the effort to map the pedestrian infrastructure in your area! Great job! Regarding improving the model, this means additional training on new regions and for that, we need training data from your region: the orthorectified imagery together with the planimetric polygons of roads, sidewalks and crosswalks, created based on the imagery so we can generate the training labels. Once we have that, I can go ahead and train the model on the new dataset.
Regarding QGIS, to be honest, I only use it for tiling purposes, and the version I am using now is : 3.30.3-'s-Hertogenbosch - QGIS code revision c006973ad1 on linux. I am not sure in what way your output is different, but i could see that the tiling was not done correctly for some reason. Our plan is to implement our own version of tiling later, as part of Tile2Net, so users are nor dependent on another tool to tile up their large images.
Since this was not a problem with Tile2Net and hopefully it is resolved now, I close this issue!
@Mary-h86 I recently generated my own tiles from a drone image with QGIS as you recommended in the issue #34 Here the output 👇
However, when I run my code especially in
raster.generate(2)
in Google Colab I have problems, first it does not generate thestructure.json
as in the reproducible example, so I wonder how can I implement my own image with tile2net in this part?