aletrn commited on
Commit
c07ce51
·
1 Parent(s): 6c70a52

[test] set some logs ad debug

Browse files
src/io/coordinates_pixel_conversion.py CHANGED
@@ -12,18 +12,18 @@ class PixelCoordinate(TypedDict):
12
 
13
 
14
  def get_latlng2pixel_projection(latlng: LatLngDict) -> PixelCoordinate:
15
- app_logger.info(f"latlng: {type(latlng)}, value:{latlng}.")
16
- app_logger.info(f'latlng lat: {type(latlng.lat)}, value:{latlng.lat}.')
17
- app_logger.info(f'latlng lng: {type(latlng.lng)}, value:{latlng.lng}.')
18
  try:
19
  sin_y: float = math.sin(latlng.lat * math.pi / 180)
20
- app_logger.info(f"sin_y, #1:{sin_y}.")
21
  sin_y = min(max(sin_y, -0.9999), 0.9999)
22
- app_logger.info(f"sin_y, #2:{sin_y}.")
23
  x = TILE_SIZE * (0.5 + latlng.lng / 360)
24
- app_logger.info(f"x:{x}.")
25
  y = TILE_SIZE * (0.5 - math.log((1 + sin_y) / (1 - sin_y)) / (4 * math.pi))
26
- app_logger.info(f"y:{y}.")
27
 
28
  return {"x": x, "y": y}
29
  except Exception as e_get_latlng2pixel_projection:
@@ -34,9 +34,9 @@ def get_latlng2pixel_projection(latlng: LatLngDict) -> PixelCoordinate:
34
  def get_point_latlng_to_pixel_coordinates(latlng: LatLngDict, zoom: int | float) -> PixelCoordinate:
35
  try:
36
  world_coordinate: PixelCoordinate = get_latlng2pixel_projection(latlng)
37
- app_logger.info(f"world_coordinate:{world_coordinate}.")
38
  scale: int = pow(2, zoom)
39
- app_logger.info(f"scale:{scale}.")
40
  return PixelCoordinate(
41
  x=math.floor(world_coordinate["x"] * scale),
42
  y=math.floor(world_coordinate["y"] * scale)
@@ -53,13 +53,13 @@ def get_latlng_to_pixel_coordinates(
53
  zoom: int | float,
54
  k: str
55
  ):
56
- app_logger.info(f"latlng_origin - {k}: {type(latlng_origin_ne)}, value:{latlng_origin_ne}.")
57
- app_logger.info(f"latlng_current_point - {k}: {type(latlng_current_point)}, value:{latlng_current_point}.")
58
  latlng_map_origin_ne = get_point_latlng_to_pixel_coordinates(latlng_origin_ne, zoom)
59
  latlng_map_origin_sw = get_point_latlng_to_pixel_coordinates(latlng_origin_sw, zoom)
60
  latlng_map_current_point = get_point_latlng_to_pixel_coordinates(latlng_current_point, zoom)
61
  diff_coord_x = abs(latlng_map_origin_sw["x"] - latlng_map_current_point["x"])
62
  diff_coord_y = abs(latlng_map_origin_ne["y"] - latlng_map_current_point["y"])
63
  point = PixelCoordinate(x=diff_coord_x, y=diff_coord_y)
64
- app_logger.info(f"point type - {k}: {point}.")
65
  return point
 
12
 
13
 
14
  def get_latlng2pixel_projection(latlng: LatLngDict) -> PixelCoordinate:
15
+ app_logger.debug(f"latlng: {type(latlng)}, value:{latlng}.")
16
+ app_logger.debug(f'latlng lat: {type(latlng.lat)}, value:{latlng.lat}.')
17
+ app_logger.debug(f'latlng lng: {type(latlng.lng)}, value:{latlng.lng}.')
18
  try:
19
  sin_y: float = math.sin(latlng.lat * math.pi / 180)
20
+ app_logger.debug(f"sin_y, #1:{sin_y}.")
21
  sin_y = min(max(sin_y, -0.9999), 0.9999)
22
+ app_logger.debug(f"sin_y, #2:{sin_y}.")
23
  x = TILE_SIZE * (0.5 + latlng.lng / 360)
24
+ app_logger.debug(f"x:{x}.")
25
  y = TILE_SIZE * (0.5 - math.log((1 + sin_y) / (1 - sin_y)) / (4 * math.pi))
26
+ app_logger.debug(f"y:{y}.")
27
 
28
  return {"x": x, "y": y}
29
  except Exception as e_get_latlng2pixel_projection:
 
34
  def get_point_latlng_to_pixel_coordinates(latlng: LatLngDict, zoom: int | float) -> PixelCoordinate:
35
  try:
36
  world_coordinate: PixelCoordinate = get_latlng2pixel_projection(latlng)
37
+ app_logger.debug(f"world_coordinate:{world_coordinate}.")
38
  scale: int = pow(2, zoom)
39
+ app_logger.debug(f"scale:{scale}.")
40
  return PixelCoordinate(
41
  x=math.floor(world_coordinate["x"] * scale),
42
  y=math.floor(world_coordinate["y"] * scale)
 
53
  zoom: int | float,
54
  k: str
55
  ):
56
+ app_logger.debug(f"latlng_origin - {k}: {type(latlng_origin_ne)}, value:{latlng_origin_ne}.")
57
+ app_logger.debug(f"latlng_current_point - {k}: {type(latlng_current_point)}, value:{latlng_current_point}.")
58
  latlng_map_origin_ne = get_point_latlng_to_pixel_coordinates(latlng_origin_ne, zoom)
59
  latlng_map_origin_sw = get_point_latlng_to_pixel_coordinates(latlng_origin_sw, zoom)
60
  latlng_map_current_point = get_point_latlng_to_pixel_coordinates(latlng_current_point, zoom)
61
  diff_coord_x = abs(latlng_map_origin_sw["x"] - latlng_map_current_point["x"])
62
  diff_coord_y = abs(latlng_map_origin_ne["y"] - latlng_map_current_point["y"])
63
  point = PixelCoordinate(x=diff_coord_x, y=diff_coord_y)
64
+ app_logger.debug(f"point type - {k}: {point}.")
65
  return point
src/prediction_api/predictors.py CHANGED
@@ -30,7 +30,7 @@ def samexporter_predict(bbox, prompt: list[dict], zoom: float, model_name: str =
30
  app_logger.info(f"img type {type(img)} with shape/size:{img.size}, matrix:{matrix}.")
31
 
32
  transform = get_affine_transform_from_gdal(matrix)
33
- app_logger.debug(f"transform to consume with rasterio.shapes: {type(transform)}, {transform}.")
34
 
35
  mask, n_predictions = get_raster_inference(img, prompt, models_instance, model_name)
36
  app_logger.info(f"created {n_predictions} masks, preparing conversion to geojson...")
 
30
  app_logger.info(f"img type {type(img)} with shape/size:{img.size}, matrix:{matrix}.")
31
 
32
  transform = get_affine_transform_from_gdal(matrix)
33
+ app_logger.info(f"transform to consume with rasterio.shapes: {type(transform)}, {transform}.")
34
 
35
  mask, n_predictions = get_raster_inference(img, prompt, models_instance, model_name)
36
  app_logger.info(f"created {n_predictions} masks, preparing conversion to geojson...")