leocvml / mxnet-im2rec_tutorial Goto Github PK
View Code? Open in Web Editor NEWthis simple tutorial will introduce how to use im2rec for mx.image.ImageIter , ImageDetIter and how to use im2rec for COCO DataSet
this simple tutorial will introduce how to use im2rec for mx.image.ImageIter , ImageDetIter and how to use im2rec for COCO DataSet
I am trying to follow the example https://mxnet.incubator.apache.org/versions/master/faq/recordio.html and create my own dataset for training using MXnet. My data is organized as specified in the example:
/data
file1.jpg
file2.jpg
the output data1.lst
The format is:
integer_image_index \t label_index \t path_to_image
But i don't know if my output is it correct??
from skimage import io
test='C:\Users\Admin\Desktop\test.lst' # folder where must be my test.lst
test='C:/Users/Admin/Desktop/test.lst'
DataSet='C:/Users/Admin/Downloads/mypic/'
data_iter = mx.image.ImageIter(
batch_size=4,
data_shape=(3,816, 1232),
label_width=4,
path_imglist='C:/Users/Admin/Desktop/test.lst',
path_root='DataSet')
for data in data_iter: d = data.data[0]
break
for data in data_iter: d = data.data[0]
... break
File "", line 2
break
^
SyntaxError: invalid syntax
=================================
then
import numpy as nd
img =nd.transpose(d,(0,2,3,1))
===== Error
Traceback (most recent call last):
File "", line 1, in
NameError: name 'd' is not defined
d
Traceback (most recent call last):
File "", line 1, in
NameError: name 'd' is not defined
train_iter = mx.image.ImageIter(
... batch_size=32,
... data_shape=(3, 816, 1232),
... path_imgrec='C:/Users/Admin/Downloads/mypic/data.rec',
... path_imgidx='C:/Users/Admin/Downloads/mypic/data.idx', #help shuffle perform
ance
... shuffle=True,
... aug_list=[mx.image.HorizontalFlipAug(0.5)]
... )
============i get next errors
Traceback (most recent call last):
File "", line 7, in
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\image\image.py", line 1061, in init
self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # p
ylint: disable=redefined-variable-type
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\recordio.py", line 199, in init
super(MXIndexedRecordIO, self).init(uri, flag)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\recordio.py", line 69, in init
self.open()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\recordio.py", line 202, in open
super(MXIndexedRecordIO, self).open()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\recordio.py", line 77, in open
check_call(_LIB.MXRecordIOReaderCreate(self.uri, ctypes.byref(self.handle)))
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\mxnet\base.py", line 149, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [17:17:32] C:\projects\mxnet-distro-win\mxnet-build\3rdpa
rty\dmlc-core\src\io\local_filesys.cc:166: Check failed: allow_null LocalFileSy
stem::Open "C:/Users/Admin/Downloads/mypic/data.rec": No such file or directory
... train_iter.reset()
Traceback (most recent call last):
File "", line 2, in
TypeError: reset() missing 1 required positional argument: 'self'
How to fix it?
When i try create .rec files using im2rec.py
github.com
apache/incubator-mxnet/blob/master/tools/im2rec.py
i get these errors,what does it mean and how to fix
machine:~$ python Downloads/im2rec.py Downloads/train –center-crop --resize 224 --pack-label
Creating .rec file from /home/opencv/Downloads/train/dog.lst in /home/opencv/Downloads/train
multiprocessing not available, fall back to single threaded encoding
imread read blank (None) image for file: /home/opencv/–center-crop/Downloads/img/h_101.jpg
Traceback (most recent call last):
File “Downloads/im2rec.py”, line 386, in
record.write_idx(item[0], s)
File “/home/opencv/.local/lib/python2.7/site-packages/mxnet/recordio.py”, line 285, in write_idx
self.write(buf)
File “/home/opencv/.local/lib/python2.7/site-packages/mxnet/recordio.py”, line 135, in write
ctypes.c_size_t(len(buf))))
TypeError: object of type ‘NoneType’ has no len()
hi, thank you for your nice code. i am a newbie in programming, would you please tell me more about how to run the generate dataset.lst code properly?
i have image stored under train folder, with images named as id_1_labels_[95, 66, 137, 70, 20].jpg. inside [] are the label of the image. i tried to run the generate dataset.lst code as:
python lstgen.py /Users/Anna/.kaggle/competitions/imaterialistchallengefashion2018/train
but the .lst file doesn't look right. thank you for your valuable help.
I want create .rec file (ubuntu 18)
So i have im2rec.py
then traim with .lst
i do so
python /home/Downloads/im2rec.py /home/Downloads/train ’ --center-crop True --resize 224 --pack-label True
and then get this error
im2rec.py: error: unrecognized arguments TRUE
How to fix it?
pencv@opencv-virtual-machine:~$ python /home/opencv/Downloads/im2rec.py /home/opencv/train . --resize 224 --pack-label True
usage: im2rec.py [-h] [–list] [–exts EXTS [EXTS …]] [–chunks CHUNKS]
[–train-ratio TRAIN_RATIO] [–test-ratio TEST_RATIO]
[–recursive] [–no-shuffle] [–pass-through]
[–resize RESIZE] [–center-crop] [–quality QUALITY]
[–num-thread NUM_THREAD] [–color {-1,0,1}]
[–encoding {.jpg,.png}] [–pack-label]
prefix root
im2rec.py: error: unrecognized arguments: True
my file taken from i didn edit it
https://github.com/apache/incubator-mxnet/blob/master/tools/im2rec.py
你好,我按照你的方法制作了多目标检测的.rec和.idx文件,但是读取的时候出现 Encounter sample with no valid label 错误,能帮我看一下吗?多谢了
这是我生成.lst文件的程序
with open('dataset/dataset.lst', 'w+') as f:
----f.truncate()
----for i in range(len(labels)):
--------lst = str(i) + '\t' + str(4) + '\t' + str(5) + '\t' + str(1360) + '\t' + str(800) + '\t'
--------for label in labels[i]:
------------lst += str(label[4]) + '\t' + str(round(label[0]/1360, 4)) + '\t' + str(round(label[1]/800,4)) + '\t'
------------lst += str(round(label[2]/1360,4)) + '\t' +str(round(label[3]/800,4)) + '\t'
--------lst += str(i).zfill(5) + '.jpg\n'
--------f.write(lst)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.