hhk7734 / wiki.loliot.net

14 stars 9 forks source link

docs/lang/python/libraries/yolov4/python-yolov4-about/ #9

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

TensorFlow 2 YOLOv4 | loliot

YOLOv4 Implemented in Tensorflow 2.

https://wiki.loliot.net/docs/lang/python/libraries/yolov4/python-yolov4-about

tarunmcom commented 3 years ago

load_tflite module is not there. I am getting error: yolo.load_tflite("yolov4-float16.tflite") AttributeError: 'YOLOv4' object has no attribute 'load_tflite' Any idea?

hhk7734 commented 3 years ago

@tarunmcom

Would you share your script?

Krakitten commented 3 years ago

Hello,

I am trying to quantize the tiny yolov4, but I am getting an error.

fully_quantize: 0, inference_type: 6, input_inference_type: 3, output_inference_type: 0 loc("yolov4-tiny-relu-tpu/route_10/concat"): error: 'tfl.concatenation' op quantization parameters violate the same scale constraint: !quant.uniform<i8:f32, 4.5647363662719727:-128> vs. !quant.uniform<i8:f32, 8.0286111831665039:-128>

I got the weights from training in darknet instead of the directions in the training section. The model works in darknet with the relu config file in the edge tpu section.

I am able to get a tflite model with float16 quantization, but not with int8 quantization

I did see concatenation in the list of ops that the TPU could do in the shown output of your edge tpu convert.

Any ideas on how to fix this. Thanks

TF 2.5.0 numpy 1.19.5

Krakitten commented 3 years ago

I added converter.experimental_new_quantizer = False in the tflite.py from the yolo package.

Able to convert the model and compile it with edge TPU. I havent run it on the stick yet, but it appears all is good.

vuanh2112000 commented 3 years ago

can u help me? error in line: yolo.make_model() thank u

Ehtsham007 commented 2 years ago

Can someone guide here to train custom dataset on this code ?

twest49 commented 2 years ago

Hello, I am trying to do a full_int8 tflite conversion with the code given in this documentation. I am using your yolov4-tiny-relu.cfg and yolov4-tiny-relu.weights.

When doing so I get a fatal python error:

WARNING:absl:Please consider switching to the new converter by setting experimental_new_converter=True. The old converter (TOCO) is deprecated. Traceback (most recent call last): File "c:\Users\xxx\Documents\xxx\python\tflite_conversion.py", line 25, in save_as_tflite( File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\yolov4\tf\utils\tflite.py", line 87, in save_as_tflite tflite_model = converter.convert() File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\lite.py", line 729, in wrapper return self._convert_and_export_metrics(convert_func, *args, kwargs) File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\lite.py", line 715, in _convert_and_export_metrics result = convert_func(self, *args, *kwargs) File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\lite.py", line 1128, in convert return super(TFLiteKerasModelConverterV2, File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\lite.py", line 897, in convert result = _toco_convert_impl( File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert_phase.py", line 215, in wrapper raise converter_error from None # Re-throws the exception. File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert_phase.py", line 208, in wrapper return func(args, kwargs) File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert.py", line 795, in toco_convert_impl data = toco_convert_protos( File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert.py", line 315, in toco_convert_protos return _run_toco_binary(model_flags_str, toco_flags_str, input_data_str, File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert_phase.py", line 215, in wrapper raise converter_error from None # Re-throws the exception. File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert_phase.py", line 208, in wrapper return func(*args, **kwargs) File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\python\convert.py", line 416, in _run_toco_binary raise ConverterError("See console for info.\n%s\n%s\n" % (stdout, stderr)) tensorflow.lite.python.convert_phase.ConverterError: See console for info. 2022-01-07 11:43:07.767293: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-01-07 11:43:07.800913: I tensorflow/lite/toco/import_tensorflow.cc:695] Converting unsupported operation: StatelessIf 2022-01-07 11:43:07.800949: F tensorflow/lite/toco/import_tensorflow.cc:116] Check failed: attr.value_case() == AttrValue::kType (1 vs. 6) Fatal Python error: Aborted

Current thread 0x00003ff4 (most recent call first): File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 50 in execute File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\absl\app.py", line 258 in _run_main File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\absl\app.py", line 312 in run File "C:\ProgramData\anaconda3\envs\xxx\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 93 in main File "C:\ProgramData\anaconda3\envs\xxx\Scripts\toco_from_protos-script.py", line 10 in

Do you have an idea on how to fix this? Thank you.

TF Version 2.6.0 yolov4 Version 3.2.0

pentanol2 commented 2 years ago

What are the compatible packages with this version of YOLO. Could you just add that as a requirements.txt

MAGomes95 commented 1 year ago

How can I have images that have no object of interest to detect in the .txt files where the bounding box coordinates are present? I have already tried to have an image associated with no class label or bounding box and it resulted in a parsing error of the train dataset.

Thank you :)

s-imanaka commented 3 months ago

just copying the inference sample code, it does not work. (tensorflow v2)

it just says KeyError: 'net'. All the resource files were downloaded previously and were set in the same directory.

NOOOREMALISs commented 1 month ago

pip install tensorflow==2.12.0 worked for me