Open stansf opened 12 months ago
Hello @stansf ,
I have same problems, it looks like arguments of the function cuspatial.point_in_polygon() are not correct, according to the documentation: https://docs.rapids.ai/api/cuspatial/nightly/api_docs/spatial/#cuspatial.point_in_polygon
The signature is: cuspatial.point_in_polygon(points: GeoSeries, polygons: GeoSeries)
I use cuspatial 23.8.1.
I managed to make it work with a workaround:
Import "sPoint" and "sPolygon" from shapely: To add at begining of plane_evaluation.py script. I used the "s" (for Shapely) prefix for sPoint and sPolygon because Polygon already exists:
from shapely import Polygon as sPolygon
from shapely import Point as sPoint
Conversion of the points into cuspatial.Geoseries: To add in plane_evaluation.py script, just before the cuspatial.point_in_polygon() call (l.182):
points = cs.GeoSeries([sPoint(p_x[idx], p_y[idx]) for idx in range(len(p_x))])
Add a function make_polygons(): (add it wherever in the script, for example at the end).
def make_polygons(poly_x, poly_y):
polygons = []
sx, sy = poly_x[0], poly_y[0]
p = [(sx, sy)]
nb_points = len(poly_x)
flag = False
for i, (x, y) in enumerate(zip(poly_x, poly_y)):
if i!=0:
p.append((x, y))
if (x==sx) and (y==sy):
if flag:
flag = False
else:
polygons.append(sPolygon(p))
p = []
if i != nb_points-1:
sx, sy = poly_x[i+1], poly_y[i+1]
flag = True
return polygons
Conversion of the polygons into a cuspatial.GeoSeries: To add in plane_evaluation.py script, just before the cuspatial.point_in_polygon() call (l.182):
p_x = list(self.points_x.to_numpy())
p_y = list(self.points_y.to_numpy())
poly_x = list(poly_dict['poly_points_x'].to_numpy())
poly_y = list(poly_dict['poly_points_y'].to_numpy())
polygons = cs.GeoSeries(make_polygons(poly_x, poly_y))
Replace the cuspatial.point_in_polygon() call to one with correct arguments: To add in plane_evaluation.py script l.182:
# mask_frame = cs.point_in_polygon(self.points_x, self.points_y, **poly_dict) # old call is commented
mask_frame = cs.point_in_polygon(points ,polygons)
This workaround worked for me, but inference time is a bit long and I think it is due to this function call, I get around 5s/image on a Nvidia P100 GPU, and I don't know how fast it should be.
Tell me if that works for you
Thanks for reporting the issue. I'll adapt the project to the latest cuspatial docker and lock down the version.
If I run into problems I'll lock to an older cuspatial docker.
@DavidGillsjo Did you manage to update the docker? Can't get this to work at all on my machine.
I did manage to get the code running with the newer cu-spatial version. See this branch.
Unfortunately I did not get the same performance with the old model weights, so there might be a bug or possibly a need to retrain the model using the new functions.
I'm afraid I don't have the time or resources to retrain the model, but if I find some time I will continue with the debugging.
Hello @DavidGillsjo, Have you made any progress in improving the results (weights) for the inference_issues branch?
Hello! What version of the
cuspatial
package are you actually using?In instruction Docker image
rapidsai/rapidsai:cuda11.5-runtime-ubuntu20.04-py3.8
is used which hasrapids
of version23.04
. But, probably, in this version the API ofcuspatial.point_in_polygon
was changed andtest.py
fails:TypeError: point_in_polygon() got an unexpected keyword argument 'poly_points_x'