You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2024/06/21 07:14:00 UTC

[jira] [Updated] (CAMEL-20895) camel-djl - The image classification predictors should not round the resulted probabilities

     [ https://issues.apache.org/jira/browse/CAMEL-20895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-20895:
--------------------------------
    Fix Version/s: 4.7.0

> camel-djl - The image classification predictors should not round the resulted probabilities
> -------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-20895
>                 URL: https://issues.apache.org/jira/browse/CAMEL-20895
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-ai
>    Affects Versions: 4.6.0
>            Reporter: Tadayoshi Sato
>            Assignee: Tadayoshi Sato
>            Priority: Major
>             Fix For: 4.7.0
>
>
> Currently, both {{ZooImageClassificationPredictor}} and {{CustomImageClassificationPredictor}} transform the resulted {{Classifications}} objects into maps of {{Map<String, Float>}}. However, the data type of {{Classifications}} is a map from the class name to probability with {{String -> Double}}, thus the precision is lost in the mapping.
> It doesn't seem to be a good transformation in the following points:
> - Sometimes rounding from double to float loses not only precision but also accuracy of the value
> - The [Softmax|https://en.wikipedia.org/wiki/Softmax_function] function used in the classification problems expects the probabilities to sum up to {{1.0}}, but due to the loss of accuracy above the premise seems to be broken to a large extent.
> - Finally, probably it's just better to simply return the {{Classifications}} object rather than converting it to a {{Map}} because the class already provides useful methods such as {{best()}}, {{topK()}}, etc. so that downstream components can easily extract the conclusions from the output out of the box; if we just provide it as a map, downstream is required to craft some manual calculations upon the result every time.
> In conclusion, I think it's better for {{ZooImageClassificationPredictor}} and {{CustomImageClassificationPredictor}} to simply return the output as {{Classifications}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)