Skip to content

Conversation

@neo1908
Copy link
Contributor

@neo1908 neo1908 commented Nov 20, 2025

The HuggingFace Inference API requires proper image MIME types
(image/jpeg, image/png, etc.) instead of application/octet-stream.

Changes:

  • Added detectImageFormat() function to detect image format from magic bytes
  • Updated ClassifyFromBytes() to use correct Content-Type header
  • Updated detectNSFWHF() to use correct Content-Type header
  • Supports JPEG, PNG, GIF, WebP, BMP, and TIFF formats
  • Falls back to image/jpeg for unknown formats

This fix resolves API errors when calling HuggingFace image
classification and NSFW detection endpoints.

The HuggingFace Inference API requires proper image MIME types
(image/jpeg, image/png, etc.) instead of application/octet-stream.

Changes:
- Added detectImageFormat() function to detect image format from magic bytes
- Updated ClassifyFromBytes() to use correct Content-Type header
- Updated detectNSFWHF() to use correct Content-Type header
- Supports JPEG, PNG, GIF, WebP, BMP, and TIFF formats
- Falls back to image/jpeg for unknown formats

This fix resolves API errors when calling HuggingFace image
classification and NSFW detection endpoints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants