DoubangoTelecom / ultimateALPR-SDK

World's fastest ANPR / ALPR implementation for CPUs, GPUs, VPUs and NPUs using deep learning (Tensorflow, Tensorflow lite, TensorRT, OpenVX, OpenVINO). Multi-Charset (Latin, Korean, Chinese) & Multi-OS (Jetson, Android, Raspberry Pi, Linux, Windows) & Multi-Arch (ARM, x86).
https://www.doubango.org/webapps/alpr/
Other
625 stars 160 forks source link

wrong model for car #125

Closed PolywickStudio closed 3 years ago

PolywickStudio commented 3 years ago

Is there a way to detect correct model? I have an image. Is there a way to confidentially pass an image via Github?

I get a different make, on SDK, than on your cloud.

DoubangoTelecom commented 3 years ago

Please clearly explain your issue and attach sample image to reproduce.

PolywickStudio commented 3 years ago

Please see attached. 15_13_00_997_AA0948IE_ID_11

This is the json.config: { "debug_level": "fatal", "debug_write_input_image_enabled": false, "debug_internal_data_path": ".", "num_threads": -1, "gpgpu_enabled": true, "max_latency": -1, "openvino_enabled": true, "openvino_device": "CPU", "detect_minscore": 0.3, "detect_roi": [0, 0, 0, 0], "pyramidal_search_enabled": true, "pyramidal_search_sensitivity": 0.33, "pyramidal_search_minscore": 0.3, "pyramidal_search_min_image_size_inpixels": 800, "klass_lpci_enabled": true, "klass_vcr_enabled": true, "klass_vmmr_enabled": true, "klass_vcr_gamma": 1.5, "recogn_minscore": 0.2, "recogn_score_type": "min", "recogn_rectify_enabled": false, "assets_folder": "(PATH)\assets", "charset": "latin", "license_token_data": "" }

I get: {"duration":1841,"frame_id":0,"plates":[{"car":{"color":[{"confidence":99.99981,"klass":-1,"name":"b"},{"confidence":9.024971e-05,"klass":-1,"name":"g"},{"confidence":8.101544e-05,"klass":-1,"name":"p"},{"confidence":1.275694e-05,"klass":-1,"name":"b"},{"confidence":3.176053e-06,"klass":-1,"name":"g"}],"confidence":100.0,"makeModelYear":[{"confidence":83.20805,"klass":-1,"make":"toyota","model":"c","year":"0-9"},{"confidence":8.748661,"klass":-1,"make":"kia","model":"c","year":"0-9"},{"confidence":6.191725,"klass":-1,"make":"kia","model":"s","year":"0-9"},{"confidence":0.485078,"klass":-1,"make":"daewoo","model":"l","year":"0-9"},{"confidence":0.2668213,"klass":-1,"make":"toyota","model":"a","year":"0-9"}],"warpedBox":[553.4474,149.4769,1301.666,149.4769,1301.666,949.0868,553.4474,949.0868]},"confidences":[89.67603,99.99702],"country":[{"code":"UKR","confidence":99.95443,"klass":74,"name":"Ukraine"},{"code":"KGZ","confidence":0.02305377,"klass":48,"name":"Kyrgyzstan"},{"code":"BGR","confidence":0.009920324,"klass":14,"name":"Bulgaria"},{"code":"ALB","confidence":0.004741127,"klass":0,"name":"Albania"},{"code":"UZB","confidence":0.00241803,"klass":126,"name":"Uzbekistan"}],"text":"AA0948I*","warpedBox":[830.2607,766.4832,1061.168,766.4832,1061.168,849.9224,830.2607,849.9224]}]}

This is a different result from your cloud. Thoughts?

PolywickStudio commented 3 years ago

This is the Cloud result:

{
blocks : [
{
car : {
bodyStyle : [
{
confidence :  86.01268768310547,
klass :  7,
name :  "mpv"
},
{
confidence :  12.2697114944458,
klass :  9,
name :  "sedan"
},
{
confidence :  0.6948904991149902,
klass :  11,
name :  "van"
},
{
confidence :  0.6340841054916382,
klass :  10,
name :  "suv"
},
{
confidence :  0.3763120174407959,
klass :  4,
name :  "hatchback"
}
],
color : [
{
confidence :  99.99315643310547,
klass :  1,
name :  "blue"
},
{
confidence :  0.0065081859938800335,
klass :  7,
name :  "purple"
},
{
confidence :  0.00015678393538109958,
klass :  4,
name :  "gray"
},
{
confidence :  0.00009974864951800555,
klass :  0,
name :  "black"
},
{
confidence :  0.000052414867241168395,
klass :  11,
name :  "white"
}
],
confidence :  100,
makeModelYear : [
{
confidence :  42.06406021118164,
klass :  936,
make :  "kia",
model :  "cerato",
year :  "0-9"
},
{
confidence :  31.357440948486328,
klass :  970,
make :  "kia",
model :  "spectra",
year :  "0-9"
},
{
confidence :  23.329330444335938,
klass :  1731,
make :  "toyota",
model :  "corolla",
year :  "0-9"
},
{
confidence :  0.6163358688354492,
klass :  966,
make :  "kia",
model :  "shuma",
year :  "0-9"
},
{
confidence :  0.5983020067214966,
klass :  444,
make :  "daewoo",
model :  "lacetti",
year :  "0-9"
}
],
warppedBox : [
 201.51170264350043,
 48.64046647813585,
 448.96843295627167,
 48.64046647813585,
 448.96843295627167,
 307.4777365790473,
 201.51170264350043,
 307.4777365790473
]
},
confidences : [
 89.69861602783203,
 99.99617004394531
],
country : [
{
code :  "UKR",
confidence :  99.96708679199219,
klass :  74,
name :  "Ukraine"
},
{
code :  "BGR",
confidence :  0.010918641462922096,
klass :  14,
name :  "Bulgaria"
},
{
code :  "KGZ",
confidence :  0.010259452275931835,
klass :  48,
name :  "Kyrgyzstan"
},
{
code :  "UZB",
confidence :  0.004595886915922165,
klass :  126,
name :  "Uzbekistan"
},
{
code :  "ALB",
confidence :  0.004569851793348789,
klass :  0,
name :  "Albania"
}
],
text :  "AA0948IE",
warppedBox : [
 295.004633585612,
 245.09452989366318,
 365.6187795003255,
 245.09452989366318,
 365.6187795003255,
 271.6859987046983,
 295.004633585612,
 271.6859987046983
]
}
],
code :  200,
duration :  20,
orientation :  1,
phrase :  "OK"
}

This is the C++ SDK result:


{
    "duration": 1841,
    "frame_id": 0,
    "plates": [{
        "car": {
            "color": [{
                "confidence": 99.99981,
                "klass": -1,
                "name": "b*****"
            }, {
                "confidence": 9.024971e-05,
                "klass": -1,
                "name": "g*****"
            }, {
                "confidence": 8.101544e-05,
                "klass": -1,
                "name": "p*****"
            }, {
                "confidence": 1.275694e-05,
                "klass": -1,
                "name": "b*****"
            }, {
                "confidence": 3.176053e-06,
                "klass": -1,
                "name": "g*****"
            }],
            "confidence": 100.0,
            "makeModelYear": [{
                "confidence": 83.20805,
                "klass": -1,
                "make": "toyota",
                "model": "c*****",
                "year": "0-9"
            }, {
                "confidence": 8.748661,
                "klass": -1,
                "make": "kia",
                "model": "c*****",
                "year": "0-9"
            }, {
                "confidence": 6.191725,
                "klass": -1,
                "make": "kia",
                "model": "s*****",
                "year": "0-9"
            }, {
                "confidence": 0.485078,
                "klass": -1,
                "make": "daewoo",
                "model": "l*****",
                "year": "0-9"
            }, {
                "confidence": 0.2668213,
                "klass": -1,
                "make": "toyota",
                "model": "a*****",
                "year": "0-9"
            }],
            "warpedBox": [553.4474, 149.4769, 1301.666, 149.4769, 1301.666, 949.0868, 553.4474, 949.0868]
        },
        "confidences": [89.67603, 99.99702],
        "country": [{
            "code": "UKR",
            "confidence": 99.95443,
            "klass": 74,
            "name": "Ukraine"
        }, {
            "code": "KGZ",
            "confidence": 0.02305377,
            "klass": 48,
            "name": "Kyrgyzstan"
        }, {
            "code": "BGR",
            "confidence": 0.009920324,
            "klass": 14,
            "name": "Bulgaria"
        }, {
            "code": "ALB",
            "confidence": 0.004741127,
            "klass": 0,
            "name": "Albania"
        }, {
            "code": "UZB",
            "confidence": 0.00241803,
            "klass": 126,
            "name": "Uzbekistan"
        }],
        "text": "AA0948I*",
        "warpedBox": [830.2607, 766.4832, 1061.168, 766.4832, 1061.168, 849.9224, 830.2607, 849.9224]
    }]
}
PolywickStudio commented 3 years ago

C++ code:

    std::string jsonConfig = jsonConfig1;
    UltAlprSdkResult result;
    MyUltAlprSdkParallelDeliveryCallback parallelDeliveryCallbackCallback;
    result = UltAlprSdkEngine::init(
        ASSET_MGR_PARAM()
        jsonConfig.c_str(),
        nullptr);// ,//&parallelDeliveryCallbackCallback);
      ....

// (HGlobal data from JPeg loading from memory)

    unsigned char* pBytes;
    if (pBytes = (unsigned char*)GlobalLock(bb)) {
        iln = (DWORD)GlobalSize(bb);
    }

    int width, height, channels;
    int typebits = 0;
    stbi_uc* uncompressedData = stbi_load_from_memory(pBytes, iln, &width, &height, &channels, typebits);
    //

    UltAlprSdkResult result;
    result = UltAlprSdkEngine::process(
        (ULTALPR_SDK_IMAGE_TYPE)typebits, // If you're using data from your camera then, the type would be YUV-family instead of RGB-family. https://www.doubango.org/SDKs/anpr/docs/cpp-api.html#_CPPv4N15ultimateAlprSdk22ULTALPR_SDK_IMAGE_TYPEE
        uncompressedData, //here is image data. ?If here we will put TBitmap
        width,
        height
    );
DoubangoTelecom commented 3 years ago

You cannot expect 2 different systems to return the exact same result. 1/ the cloud uses different configuration values 2/ the cloud uses gpu and you may be using cpu. The math is different 3/ the cloud uses Tensorflow 14 while you may be using Tensorflow 15 (if you're using Windows) 4/ the cloud runs on Ubuntu 18, you may be using different OS (maybe windows) 5/ the cloud uses Tensorflow and you may be using OpenVINO, TensorRT... again, I don't have any idea about your OS as you haven't attached your logs 6/ last but not least, the cloud is always a version ahead of the sdk (see opene issues)

PolywickStudio commented 3 years ago

Problem:

For the image, I get wrong model information.

DoubangoTelecom commented 3 years ago

Tried with version 3.2 on Windows:

recognizer.exe ^
    --image C:/Users/dmi/Desktop/safe.jpg ^
    --assets ../../../assets ^
    --charset latin ^
    --car_noplate_detect_enabled false ^
    --ienv_enabled true ^
    --openvino_enabled true ^
    --openvino_device CPU ^
    --klass_lpci_enabled true ^
    --klass_vcr_enabled true ^
    --klass_vmmr_enabled true ^
    --klass_vbsr_enabled true ^
    --parallel false

Result:

*[ULTALPR_SDK INFO]: result: {"duration":678,"frame_id":0,"plates":[{"car":{"bod
yStyle":[{"confidence":91.81168,"klass":-1,"name":"m*****"},{"confidence":7.0764
11,"klass":-1,"name":"s*****"},{"confidence":0.4673381,"klass":-1,"name":"s*****
"},{"confidence":0.4603949,"klass":-1,"name":"v*****"},{"confidence":0.1630015,"
klass":-1,"name":"h*****"}],"color":[{"confidence":99.98067,"klass":-1,"name":"b
*****"},{"confidence":0.0186839,"klass":-1,"name":"p*****"},{"confidence":0.0004
166623,"klass":-1,"name":"g*****"},{"confidence":0.0001483097,"klass":-1,"name":
"b*****"},{"confidence":2.4586e-05,"klass":-1,"name":"w*****"}],"confidence":100
.0,"makeModelYear":[{"confidence":40.41494,"klass":-1,"make":"kia","model":"c***
**","year":"0-9"},{"confidence":31.68861,"klass":-1,"make":"toyota","model":"c**
***","year":"0-9"},{"confidence":22.25767,"klass":-1,"make":"kia","model":"s****
*","year":"0-9"},{"confidence":1.625271,"klass":-1,"make":"daewoo","model":"l***
**","year":"0-9"},{"confidence":1.185036,"klass":-1,"make":"chevrolet","model":"
e*****","year":"0-9"}],"warpedBox":[553.8641,157.5091,1296.34,157.5091,1296.34,9
58.7792,553.8641,958.7792]},"confidences":[89.76413,99.99681],"country":[{"code"
:"UKR","confidence":99.7989,"klass":74,"name":"Ukraine"},{"code":"BGR","confiden
ce":0.1082477,"klass":14,"name":"Bulgaria"},{"code":"KGZ","confidence":0.0478678
5,"klass":48,"name":"Kyrgyzstan"},{"code":"ALB","confidence":0.03089227,"klass":
0,"name":"Albania"},{"code":"UZB","confidence":0.003773962,"klass":126,"name":"U
zbekistan"}],"text":"AA0948I*","warpedBox":[830.4261,766.7983,1061.229,766.7983,
1061.229,849.7116,830.4261,849.7116]}]}

which is correct with both Tensorflow and OpenVINO

PolywickStudio commented 3 years ago

Please mark as fixed. I forgot to update Json file which was changed/updated with new parameters in the latest BuildJson(..)

PolywickStudio commented 3 years ago

btw, congrats it seems your SDK become much faster with this build.

PolywickStudio commented 3 years ago

If any of you developers are upgrading from older SDK, remember to add to your BuildJSON:

"ienv_enabled": true "car_noplate_detect_enabled": false, "car_noplate_detect_min_score": 0.8, "klass_vbsr_enabled": false

DoubangoTelecom commented 3 years ago

btw, congrats it seems your SDK become much faster with this build.

In my JSON result it says the duration is 678 millis but this doesn't reflect the real speed. The first call is always slow as we load and init the models. To get the real speed, use benchmark application and enable OpenVINO if you don't have a GPU with CUDA: https://github.com/DoubangoTelecom/ultimateALPR-SDK/blob/master/samples/c%2B%2B/benchmark/README.md

PolywickStudio commented 3 years ago

I know that. The second instance is much faster. I'm getting less than 1 second detection on average.

PolywickStudio commented 3 years ago

^ I'm sorry. maybe you have meant I was sarcastic, that is not the case. In the previous SDK, I was getting, like, randomly sometimes 10 seconds to initialize, randomly, 3 or 4 seconds to get car detected.

Now it's less than 2 seconds to start, less than a second on average.