michaelfeil / michaelfeil/infinity
1x1 input image can crash /v1/embeddings endpoint until pod restart while health check endpoint continues to return 200
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Description
### System Info
We have an image processing pipeline where we're using Infinity behind KubeAI to compute CLIP embeddings for images.
```
curl -vv http://kubeai/openai/v1/embeddings \
--http1.1 -H "Authorization: Bearer blah" \
-H "Content-Type: application/json" \
-d '{
"input": "https://some.image.url/image.png",
"model": "infinity-hosted-clip-embedding-model",
"modality": "image"
}'
```
Every now and then we get into a situation where a single bad request comes along (working on trying to isolate it). From that point on, our steady stream of embeddings, health, and metrics calls ... becomes a steady stream of just health check and metric calls (both of which continue to return 200s). The model stays running but stops receiving any embedding requests from kubeai and we essentially lose 1/n of our throughput.
```
INFO: 10.15.5.245:57645 - "POST /v1/embeddings HTTP/1.1" 200 OK
ERROR 2025-06-26 13:23:51,860 infinity_emb ERROR: broken batch_handler.py:557
data stream when reading image file
Traceback (most recent call last):
File
"/app/infinity_emb/inference/batch_handler.py",
line 541, in _preprocess_batch
feat = self._model.encode_pre(items_for_pre)
File
"/app/infinity_emb/transformer/vision/torch_vision
.py", line 159, in encode_pre
preprocessed = self.processor(
File
"/app/.venv/lib/python3.10/site-packages/transform
ers/models/clip/processing_clip.py", line 109, in
__call__
image_features = self.image_processor(images,
return_tensors=return_tensors,
**image_processor_kwargs)
File
"/app/.venv/lib/python3.10/site-packages/transform
ers/image_processing_utils.py", line 41, in
__call__
return self.preprocess(images, **kwargs)
File
"/app/.venv/lib/python3.10/site-packages/transform
ers/models/clip/image_processing_clip.py", line
307, in preprocess
images = [convert_to_rgb(image) for image in
images]
File
"/app/.venv/lib/python3.10/site-packages/transform
ers/models/clip/image_processing_clip.py", line
307, in
images = [convert_to_rgb(image) for image in
images]
File
"/app/.venv/lib/python3.10/site-packages/transform
ers/image_transforms.py", line 776, in
convert_to_rgb
image = image.convert("RGB")
File
"/app/.venv/lib/python3.10/site-packages/PIL/Image
.py", line 995, in convert
self.load()
File
"/app/.venv/lib/python3.10/site-packages/PIL/Image
File.py", line 312, in load
raise _get_oserror(err_code, encoder=False)
OSError: broken data stream when reading image
file
```
Any ideas?
### Information
- [x] Docker + cli
- [ ] pip + cli
- [ ] pip + usage of Python interface
### Tasks
- [x] An officially supported CLI command
- [ ] My own modifications
### Reproduction
I'm trying to find the image URL that reproduces this. Will update back if I find one.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at infinity_emb/inference/batch_handler.py:541-557 and infinity_emb/transformer/vision/torch_vision.py:159, following the POST /v1/embeddings path and the reported image decode exception. Reproduce with the eventual 1x1 or otherwise bad image when available; done means a malformed image no longer leaves embedding requests stalled while health and metrics remain 200.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100