@@ -121,7 +121,7 @@ async def image_stream():
121121 yield response
122122
123123 async def classify_single (
124- self , image_data : ImageData , correlation_id : str | None = None
124+ self , image_data : ImageData
125125 ) -> ClassificationOutput :
126126 """Classify a single image synchronously without deployment context.
127127
@@ -169,18 +169,19 @@ async def classify_single(
169169 f"Weight: {classification.weight}")
170170
171171 """
172- if correlation_id is None :
173- correlation_id = str (uuid .uuid4 ())
174-
175172 processed_image = image_data
176173
177174 # Apply image resizing if enabled
178175 if self .options .resize_images :
179- processed_image = await resize_image (processed_image )
176+ processed_image = await resize_image (
177+ processed_image , self .options .resampling_algorithm
178+ )
180179
181180 # Apply compression if enabled
182181 if self .options .compress_images :
183- processed_image = compress_image (processed_image )
182+ processed_image = compress_image (
183+ processed_image , self .options .compression_quality
184+ )
184185
185186 request_encoding = (
186187 RequestEncoding .REQUEST_ENCODING_BROTLI
@@ -196,7 +197,7 @@ async def classify_single(
196197
197198 classification_input = ClassificationInput (
198199 affiliate = self .options .affiliate ,
199- correlation_id = correlation_id ,
200+ correlation_id = processed_image . correlation_id or str ( uuid . uuid4 ()) ,
200201 encoding = request_encoding ,
201202 data = processed_image .data ,
202203 format = image_format ,
@@ -240,13 +241,17 @@ async def transform_image(image_data: ImageData) -> ClassificationInput:
240241 """Transform a single image through the full pipeline."""
241242 # Apply image resizing if enabled
242243 if self .options .resize_images :
243- resized_image = await resize_image (image_data )
244+ resized_image = await resize_image (
245+ image_data , self .options .resampling_algorithm
246+ )
244247 else :
245248 resized_image = image_data
246249
247250 # Apply compression if enabled
248251 if self .options .compress_images :
249- compressed_image = compress_image (resized_image )
252+ compressed_image = compress_image (
253+ resized_image , self .options .compression_quality
254+ )
250255 else :
251256 compressed_image = resized_image
252257
@@ -257,19 +262,23 @@ async def transform_image(image_data: ImageData) -> ClassificationInput:
257262 else RequestEncoding .REQUEST_ENCODING_UNCOMPRESSED
258263 )
259264
260- # Create classification input directly
261- correlation_provider = self .options .correlation_provider ()
262-
263265 # Ensure we never send UNSPECIFIED format over the API
264266 image_format = compressed_image .image_format
265267 if image_format == ImageFormat .IMAGE_FORMAT_UNSPECIFIED :
266268 image_format = ImageFormat .IMAGE_FORMAT_RAW_UINT8_BGR
267269
270+ if compressed_image .correlation_id :
271+ correlation_id = compressed_image .correlation_id
272+ else :
273+ # Create classification input directly
274+ correlation_provider = self .options .correlation_provider ()
275+ correlation_id = correlation_provider .get_correlation_id (
276+ compressed_image .data
277+ )
278+
268279 return ClassificationInput (
269280 affiliate = self .options .affiliate ,
270- correlation_id = correlation_provider .get_correlation_id (
271- compressed_image .data
272- ),
281+ correlation_id = correlation_id ,
273282 data = compressed_image .data ,
274283 encoding = request_encoding ,
275284 format = image_format ,
0 commit comments