9
9
import tempfile
10
10
import urllib .request
11
11
from collections .abc import Sequence
12
- from typing import Any , Optional , Union
12
+ from typing import Any , Union
13
13
14
14
import albumentations
15
15
import numpy as np
@@ -98,9 +98,9 @@ def _convert_np_uint8(float_image: torch.Tensor):
98
98
99
99
100
100
def read_geotiff (
101
- file_path : Optional [ str ] = None ,
102
- path_type : Optional [ str ] = None ,
103
- file_data : Optional [ bytes ] = None ,
101
+ file_path : str | None = None ,
102
+ path_type : str | None = None ,
103
+ file_data : bytes | None = None ,
104
104
) -> tuple [torch .Tensor , dict , tuple [float , float ] | None ]:
105
105
"""Read all bands from *file_path* and return image + meta info.
106
106
@@ -114,8 +114,8 @@ def read_geotiff(
114
114
115
115
if all ([x is None for x in [file_path , path_type , file_data ]]):
116
116
raise Exception ("All input fields to read_geotiff are None" )
117
- write_to_file : Optional [ bytes ] = None
118
- path : Optional [ str ] = None
117
+ write_to_file : bytes | None = None
118
+ path : str | None = None
119
119
if file_data is not None :
120
120
# with tempfile.NamedTemporaryFile() as tmpfile:
121
121
# tmpfile.write(file_data)
@@ -162,9 +162,9 @@ def read_geotiff(
162
162
def load_image (
163
163
data : Union [list [str ]],
164
164
path_type : str ,
165
- mean : Optional [ list [float ]] = None ,
166
- std : Optional [ list [float ]] = None ,
167
- indices : Optional [ Union [list [int ], None ]] = None ,
165
+ mean : list [float ] | None = None ,
166
+ std : list [float ] | None = None ,
167
+ indices : Union [list [int ], None ] | None = None ,
168
168
):
169
169
"""Build an input example by loading images in *file_paths*.
170
170
@@ -278,7 +278,7 @@ def output_to_response(
278
278
def pre_process (
279
279
self ,
280
280
prompt : IOProcessorInput ,
281
- request_id : Optional [ str ] = None ,
281
+ request_id : str | None = None ,
282
282
** kwargs ,
283
283
) -> Union [PromptType , Sequence [PromptType ]]:
284
284
image_data = dict (prompt )
@@ -359,7 +359,7 @@ def pre_process(
359
359
def post_process (
360
360
self ,
361
361
model_output : Sequence [PoolingRequestOutput ],
362
- request_id : Optional [ str ] = None ,
362
+ request_id : str | None = None ,
363
363
** kwargs ,
364
364
) -> IOProcessorOutput :
365
365
pred_imgs_list = []
0 commit comments