PINTO0309 / OpenVINO-YoloV3

YoloV3/tiny-YoloV3+RaspberryPi3/Ubuntu LaptopPC+NCS/NCS2+USB Camera+Python+OpenVINO
https://qiita.com/PINTO
Apache License 2.0
537 stars 165 forks source link

There is a problem with the weight of training yourself. #10

Open superJerryLee opened 5 years ago

superJerryLee commented 5 years ago

There is a problem with the weight of training yourself(One classe). I followed your script.txt FP32 (CPU): frozen_tiny_yolo_v3.xml and frozen_tiny_yolo_v3.bin test is normal. FP16 (MYRIAD): frozen_tiny_yolo_v3.xml and frozen_tiny_yolo_v3.bin test showed a lot of abnormal noise. I am trying to modify yolo_v3_tiny_changed.json: [ { "id": "TFYOLOV3", "match_kind": "general", "custom_attributes": { "classes": 1, "coords": 4, "num": 6, "mask": [0,1,2], "jitter":0.3, "ignore_thresh":0.7, "truth_thresh":1, "random":1, "anchors":[10,14,23,27,37,58,81,82,135,169,344,319], "entry_points": ["detector/yolo-v3-tiny/Reshape","detector/yolo-v3-tiny/Reshape_4"] } } ]

I don't know where I need to modify it.

Can you help me to solve this problem,thank you.

PINTO0309 commented 5 years ago

@superJerryLee

It is not a problem of the program. The essence is that the accuracy of the tiny model is very bad. Editing "yolo_v3_tiny_changed.json" does not change anything. Change "Threshold (-t option)" specified at program execution. In Python version, the threshold 0.2 is hard-coded in the logic.

if obj.confidence < 0.2:
if confidence > 0.2:

The following is a sample of the execution script.

$ python3 openvino_tiny-yolov3_MultiStick_test.py -numncs 1

or

cpp/object_detection_demo_yolov3_async \
-i cam1 \
-m lrmodels/tiny-YoloV3/FP16/frozen_tiny_yolo_v3.xml \
-d MYRIAD \
-t 0.2

or

cpp/object_detection_demo_yolov3_async \
-i cam0 \
-m lrmodels/tiny-YoloV3/FP16/frozen_tiny_yolo_v3.xml \
-d MYRIAD \
-t 0.2
superJerryLee commented 5 years ago

Hi, Thank you for your reply.

I am training a module. (YOLO.weights -> .pd -> bin + xml) This module has only one category. According to your script.txt is normal under FP32 (CPU) state. But in the case of FP16 (MYRIAD) is wrong. As shown below:

screenshot from 2019-01-24 09-38-58

There are a lot of boxed numbers. This should not be normal.....

Thanks & Best Regards, Jerry

PINTO0309 commented 5 years ago

@superJerryLee

I will tell you the same thing again. Adjust the "threshold" described in the program.

For example:

objects = ParseYOLOV3Output(output, m_input_size, m_input_size, camera_height, camera_width, 0.2, objects)
0.2 -> 0.3

or

0.2 -> 0.4

or

0.2 -> 0.5

or

0.2 -> 0.6

or

0.2 -> 0.8

or

0.2 -> 0.9
superJerryLee commented 5 years ago

Hi,Excuse me Thank you for your reply.

I know how to adjust the threshold to reduce noise. But how can the results of FP32 and FP16 be completely different?(The same threshold and same Tiny)

FP32(CPU) screenshot from 2019-01-24 10-41-29

FP16(MYRIAD) screenshot from 2019-01-24 09-38-58

FP16: Each frame has hundreds of boxes...

Thanks & Best Regards, Jerry

PINTO0309 commented 5 years ago

@superJerryLee

Ummm... Same issue #2 , #6

tiny-YoloV3 is very poor accuracy... https://pjreddie.com/darknet/yolo/

Is it possible to share your model file with me? I would like to investigate on Saturday or Sunday.

superJerryLee commented 5 years ago

Hi, @PINTO0309 .. Thank you for your reply again.

My module is linked here... https://drive.google.com/open?id=1tC3ND1EHXHwiAo32c6Zi8b-N_ky3YEwY

I trained my own model with 1 class, tested it on darknet and tensorflow(.pb) and FP32, works perfectly.

Help me analyze the module..... I know that TINY-YOLO has a very low accuracy. But it should not be so much different between FP32 and FP16. FP16 box selection too many results ,So only 0.5FPS.......

This problem has been bothering me for a long time.

Thanks & Best Regards, Jerry

PINTO0309 commented 5 years ago

@superJerryLee I do not know if the position where the frame is displayed is correct. The number of frames displayed is not infinite.

class NcsWorker(object):

    def __init__(self, devid, frameBuffer, results, camera_width, camera_height, number_of_ncs, vidfps):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = "./frozen_tiny_yolo_v3.xml"
        self.model_bin = "./frozen_tiny_yolo_v3.bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.m_input_size = 416
        self.threshould = 0.55
superJerryLee commented 5 years ago

Hi, @PINTO0309 .. Thank you for your reply again.

Sorry.. I want to confirm two things.

  1. Are you converting from yoloV3-tiny.weights to FP16?
  2. If you adjust Threshould =0.2, will it be infinite?

If you confirm above, can you give me your converted FP16(xml+bin)?

Let me try to see if my environment is normal... cross validation..

Thank you again for taking the time to help me try.

Thank you

Thanks & Best Regards, Jerry

PINTO0309 commented 5 years ago

@superJerryLee

  1. Are you converting from yoloV3-tiny.weights to FP16?

Yes. I used the model file that you provided to me. (frozen_tiny_yolo_v3.bin / frozen_tiny_yolo_v3.xml)

  1. If you adjust Threshould =0.2, will it be infinite?

Threshould = 0.2 ---> Frame is displayed at infinity THreshould = 0.55 ---> The number of frames is suppressed In your model, if the threshold is too low, innumerable frames will be displayed. It means that the accuracy is better than the model I generated.

If you confirm above, can you give me your converted FP16(xml+bin)?

Your model has no flaws. I have not changed any of your model files. (.bin / .xml)

FP16 internally reduces float32 to float16 precision. It is a matter of course that arithmetic accuracy will be extremely deteriorated when converted to FP16. If you specify --log_level WARNING as an option for executing mo_tf.py, you can check that the float16 operation overflows.

superJerryLee commented 5 years ago

Hi, @PINTO0309 .. Thank you for your reply again.

If you specify --log_level WARNING as an option for executing mo_tf.py, you can check that the float16 operation overflows.

I understand.. I will try...

Converting to FP16 should be wrong...

Because the FP32's threshould =0.2 display is normal...

FP32 always has no false alarms..(FP16 frame is displayed at infinity)

Thank you again for taking the time to help me try.

Thanks & Best Regards, Jerry

PINTO0309 commented 5 years ago

There seems to be a bug in NCS 2's internal API. https://software.intel.com/en-us/forums/computer-vision/topic/804818

And, I solved the problem of low precision. There was a mistake in the logic of preprocessing and postprocessing.