<< return to Vizycam.com

Extracting Tensorflow Text Labels

Been playing around with /home/pi/vizy/examples/tensorflow/main.py* and trying to extract the text labels from _detected:

_detected = tflow.detect(frame, block=False)
# If we detect something…
if _detected is not None:
# …save for render_detected() overlay.
detected = _detected

What are the methods / attributes to extract the text labels, etc?

Are these inherited from standard tensorflow library, or has the tf library been modified for embedded purposes?

Thanks.

Hello,
Here “detected” is a list of KimagedDetected objects. You should be able to do something like:

for d in detected:
    print(d.index, d.label, d.box, d.score)

KimageDetector and KimageDetected allow us to have different object detector implementations (Tensorflow, Tensorflow Lite, PyTorch, etc.) but use the same interface.

Edward

1 Like

Hi, is there / or do you planning on publishing some documentation for KimageDetector and KimageDetected, etc. Are these binaries or can I view the source via your GitHub repository?

I’ve located: GHUB - kritter/src/kritter/tf/TFDetector.py

Great product and software. I’m used to PyCharm, but the browser Python editor works well. The Console does the job also, helps with debugging.

Any tips on setting up an env so that I can use PyCharm rather than the browser editor?

Thanks

Hello,
The source to KimageDetector and KimageDetected are here:

but KimageDetected is just a container class:

class KimageDetected:

def __init__(self, index, label, score, box):
    self.index = index
    self.label = label
    self.score = score
    self.box = box

KimageDetector.detect() returns a list of KimageDetected objects.

Hope this helps!

Regarding Pycharm, maybe you can use the network file system:
https://docs.vizycam.com/doku.php?id=wiki:file_access

and point PyCharm to the code in the directory that you mount? (I’m haven’t used PyCharm, so I’m just guessing :slight_smile: )

Edward

1 Like