tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Issues classifying images that are slighly blurred

Open aw1875 opened this issue 3 years ago • 4 comments

This may not be considered a bug as the code may be functioning properly so I wanted to drop this here.

System information

  • Tested on Ubuntu 22.04 and Windows 10
  • TFJS installed via yarn
  • TFJS version 3.19.0
  • I have written custom code (see snippet below)

Describe the current behavior It seems like TFJS paired with the cocossd model is having issues with images that are blurred or slightly blurry.

Describe the expected behavior Expecting normal image classification as per usual.

Code Snippet For reference, this code is ran in a try/catch so I can manually throw an error if the image arraybuffer request fails. This code is also written in TypeScript which is why I am casting the response from decodeImage to a Tensor3D object for coco to attempt to detect.

import tf, { Tensor3D } from '@tensorflow/tfjs-node'
import cocossd from '@tensorflow-models/coco-ssd'
import axios from 'axios'

// Get Image as arraybuffer
const blob = await axios.get(uri, { responseType: 'arraybuffer' })
    .then((res) => res.data)
    .catch((err) => { throw err; });

// Load Model
const model = await cocossd.load();

// Get Predictions
const predictions = await model.detect(tf.node.decodeImage(blob) as Tensor3D) // Leaving the default boxes and confidence
return predictions;

aw1875 avatar Aug 05 '22 04:08 aw1875

It is working on blurred images as well , here is one example , can you please share the images if possible which you are using , thank you

image

rthadur avatar Aug 09 '22 21:08 rthadur

@rthadur It does work, but sometimes it has issues is just what I've noticed. I don't have a photo from my testing handy currently but I can try and grab out later as an example.

aw1875 avatar Aug 09 '22 22:08 aw1875

sure , Thank you

rthadur avatar Aug 09 '22 22:08 rthadur

@rthadur Here's one of the examples from my testing: dog

aw1875 avatar Aug 09 '22 23:08 aw1875

@aw1875 Our package is a re-implementation of this tensorflow code, it seems to be an issue with object detection models in general (see this paper)

ahmedsabie avatar Aug 11 '22 21:08 ahmedsabie

@aw1875 Our package is a re-implementation of this tensorflow code, it seems to be an issue with object detection models in general (see this paper)

Alright so it’s just a general issue for image detection as a whole, thank you for the information!

aw1875 avatar Aug 12 '22 13:08 aw1875