Has someone successfully converted a yolov3-tiny model to Caffe? - python

I have been looking for ways to convert a custom trained yolov3-tiny network from darknet format to Caffe format, but every Python program I tried has failed. Has someone managed to do it and make it work? If so, what program or tutorial did you use and under which environment?
I have a machine with windows 10 and Visual Studio 2019 installed, and also a virtual machine with Ubuntu 18.04, in case that's any helpful.
Edit: these are some of the programs I've tried:
https://github.com/marvis/pytorch-caffe-darknet-convert
~/darknet2caffe/pytorch-caffe-darknet-convert-master$ python darknet2caffe.py ../yolov3-conos-tiny.cfg ../yolov3-conos-tiny.weights conos.prototxt conos.caffemodel
unknow layer type yolo
unknow layer type upsample
Traceback (most recent call last):
File "darknet2caffe.py", line 350, in <module>
darknet2caffe(cfgfile, weightfile, protofile, caffemodel)
File "darknet2caffe.py", line 10, in darknet2caffe
net_info = cfg2prototxt(cfgfile)
File "darknet2caffe.py", line 251, in cfg2prototxt
prev_layer_id = layer_id + int(block['layers'])
ValueError: invalid literal for int() with base 10: '-1, 8'
https://github.com/BingzheWu/object_detetction_tools
~/darknet2caffe/object_detetction_tools-master/nn_model_transform$ python darknet2caffe.py ../../yolov3-conos-tiny.cfg ../../yolov3-conos-tiny.weights conos.prototxt conos.caffemodel
Traceback (most recent call last):
File "darknet2caffe.py", line 6, in <module>
from prototxt_utils import *
File "/home/carlos/darknet2caffe/object_detetction_tools-master/nn_model_transform/prototxt_utils.py", line 151
print('%s%s {' % (blanks, prefix), end = "\n", file = fp)
^
SyntaxError: invalid syntax
https://github.com/eric612/MobileNet-YOLO/tree/master/models/darknet_yolov3
~/darknet2caffe/MobileNet-YOLO-master/models/darknet_yolov3$ python darknet2caffe.py ../../../yolov3-conos-tiny.cfg ../../../yolov3-conos-tiny.weights conos.prototxt conos.caffemodel
2
OrderedDict([('bottom', 'layer19-conv'), ('top', 'layer20-upsample'), ('name', 'layer20-upsample'), ('type', 'Upsample'), ('upsample_param', OrderedDict([('scale', '2')]))])
('upsample:', 20)
[libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format caffe.NetParameter: 636:20: Message type "caffe.LayerParameter" has no field named "upsample_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0518 13:14:19.206104 15199 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: conos.prototxt
*** Check failure stack trace: ***
Aborted (core dumped)
I am using Python 2.7 and have Caffe and Pytorch installed. I compiled the caffe library following this tutorial: https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide

Related

Error when creating own haar cascade model in python

I have allmy files ready to train my model but when i try to merge sample files
I get this error:
Traceback (most recent call last):
File "./tools/mergevec.py", line 170, in <module>
merge_vec_files(vec_directory, output_filename)
File "./tools/mergevec.py", line 120, in merge_vec_files
val = struct.unpack('<iihh', content[:12])
TypeError: a bytes-like object is required, not 'str'
i have my positive nad negative images ready and with
python ./tools/mergevec.py -v samples/ -o samples.vec
I try to merge my files but than i got above error.
And the answer that comes up on stackoverflow regarding this mistake did not work in my case

Error converting Tensorflow to coreML using tf-coreml

I want to do hand tracking with coreML.
For this, I took the ready-made tensorFlow model: https://github.com/timctho/convolutional-pose-machines-tensorflow
And I'm trying to convert it to coreML using tf-coreml. But during the conversion I get errors.
(base) MBP-Alexey:Desktop alexeygorbunov$ python convert_tf_to_coreml.py
Loading the TF graph...
Traceback (most recent call last):
File "convert_tf_to_coreml.py", line 5, in <module>
input_name_shape_dict = { ' input_placeholder: 0 ' : [ 1 , 256 , 256 , 3 ]})
File "/Users/alexeygorbunov/anaconda3/lib/python3.7/site packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
custom_conversion_functions=custom_conversion_functions)
File "/Users/alexeygorbunov/anaconda3/lib/python3.7/site-packages/tfcoreml/_tf_coreml_converter.py", line 150, in _convert_pb_to_mlmodel
gdef.ParseFromString(serialized)
google.protobuf.message.DecodeError: Error parsing message
What could be the error and how to solve it?

invalid syntax in Python function

[joepareti54#xxx build]$ ./manta ../scenes/_trainingData.py --dim 3 --addModelGeometry True --addSphereGeometry True
Version: mantaflow 64bit fp1 commit dd3bb0c0a65cc531d3c33487bde5edcb4aa6784f from Mar 14 2018, 14:53:44
Loading script '../scenes/_trainingData.py'
Traceback (most recent call last):
File "../scenes/_trainingData.py", line 12, in <module>
from Emitter import *
File "/home/joepareti54/FluidNet/manta/scenes/Emitter.py", line 15, in <module>
import matlabnoise
File "/home/joepareti54/FluidNet/manta/build/../../../matlabnoise/matlabnoise.py", line 81
def Perlin2D(*args) -> "double" :
^
SyntaxError: invalid syntax
I believe the invalid syntax occurs in:
def Perlin2D(*args) -> "double" :`enter code here`
return _matlabnoise.Perlin2D(*args)
Perlin2D = _matlabnoise.Perlin2D
Your problem is that mantaflow is running an embedded Python, so the version used is the one that was available when mantaflow was compiled and it appears that version does not support the type annotations introduced in Python 3.5
When you run which python that shows you the version of Python installed on your system, not the version compiled into the other program.
Solutions include recompiling mantaflow with a more recent Python, or stop using type annotations.

OpenCV 3.3 dnn.readNetFromTensorflow() throws error: Unknown layer type Cast in op ToFloat

First,I use the OpenCV 3.3 and the Python 3.6.
When I use
net=cv2.dnn.readNetFromCaffe('MobileNetSSD.prototxt.txt','MobileNetSSD_deploy.caffemodel'), it works.
The question is when I load the tensorflow module,there is an error:
My code is
net = cv2.dnn.readNetFromTensorflow('frozen_inference_graph_face.pb')
The wrong message is
Traceback (most recent call last):
File "F:/real-time-object-detection/real_time_object_detection.py", line 34, in <module>
net = cv2.dnn.readNetFromTensorflow('frozen_inference_graph_face.pb')
cv2.error: D:\Build\OpenCV\opencv-3.3.0\modules\dnn\src\tensorflow\tf_importer.cpp:883: error: (-2) Unknown layer type Cast in op ToFloat in function cv::dnn::experimental_dnn_v1::`anonymous-namespace'::TFImporter::populateNet

tensorflow program getting error saying KeyError: 'enc_vocab_size'

I was working on a Tensorflow program when I got an error saying
I tensorflow/core/common_runtime/direct_session.cc:255] Device mapping:
Traceback (most recent call last):
File "/Users/jenna/PycharmProjects/ai/main.py", line 23, in <module>
model = execute.create_model(sess, False)
File "/Users/jenna/PycharmProjects/ai/execute.py", line 106, in create_model
model = seq2seq_model.Seq2SeqModel(gConfig['enc_vocab_size'], gConfig['dec_vocab_size'], _buckets,
KeyError: 'enc_vocab_size'
Device mapping: no known devices.
Process finished with exit code 1
I could not figure out what to do to fix this The code is bellow please tell me.
Like of code I was using

Categories

Resources