-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating LevelDB in Python #745
Comments
Keep in mind that |
I tried using the code below to flip the axes to (channel, y, x) but still getting the same problem when training. Possibly my reshaping of the axes is incorrect though?
I've also tried this with no success either.
|
You want You might want to read You can debug by loading both working and nonworking nets in Python and comparing the data blobs. |
Nice suggestion longjon! The I've added the code below, still with the same results with training getting worse. I've also tried loading both working and nonworking networks in Python, however both nets have empty data blobs (all zeros).
Cleaning up a bit, here is my new code, still with the same problem as before though.
|
When checking in Python, did you call You can also check that the same data appear in both working and nonworking LevelDBs directly. Also check that your labels are correct, and that you are shuffling them if you need to in order to balance classes in each batch. |
Hi there, how quick is working your algorithm? I am also working with big database and process some artificial data increase. However in that way, even with batch mode, the process is dramatically slow especially for big images (3x101x101 in my case) and lead to reduce the pre-processing evaluation. Hence I have trying to parallelize the process with one batch by core for the same database but it's lead to segmentation issue with plyvel and py-leveldb (but leveldb should support multi-thread acces to 1 db according to the docs...). Therefore I have segmented my testing database but the issue is still remaining for the training case. Do you use special implementation in python to avoid this point? By the way, must the batch size should be set to 1,000 or is it just an arbitrary choice? |
If preprocessing speed and input size are important you should prepare your On Thu, Aug 21, 2014 at 8:58 AM, hnoel notifications@github.com wrote:
|
Thx @shelhamer . I will try to modify some io cpp method, it does not seem complicated. When I success I will do a PR for some classic artificial data increase (rotation, flip, scaling) that some are looking for in some other post. By the way why all the batch length must be inferior to 1,000 items ? Another question, is the key string important or can we put any string of 256 bits if all are different ? Finally have you ever tried multi-process access to a leveldb database in order to increase the speed ? |
Sounds good. leveldb is limited to single process access -- look at lmdb for On Thursday, August 21, 2014, hnoel notifications@github.com wrote:
|
Hey all, my apologies for a late reply. I did solve my problem, in fact the reason why training was getting worse over time was due to two things.
Few answers to questions asked above: _Why are all the images written to leveldb as batches of 1000 images? Is this significant?_ My code tries to duplicate what happens in convert_imageset.cpp found below (specifically at line 183). From what I tested, I didn't find the batch size to be significant in CNN training. A batch size of 100 or 10,000 shouldn't act much differently than a batch size of 1,000. The only caveat is that the batch should be representative all of image classes (randomly shuffled data). _Is the key important when saving an image into leveldb?_ Yes. I found the format of the key to be extremely important.
The line below however doesn't work when caffe tries to load the data back out of leveldb for training.
More precisely the key must be in the format of |
|
Python module db = leveldb.LevelDB('mnist-%s-leveldb/' % name, create_if_missing=True, error_if_exists=True)
for im, lb in zip(imgs, lbls):
......
db.Put('%08d' % count, datum.SerializeToString()) and db = plyvel.DB('mnist-%s-leveldb/' % name, create_if_missing=True, error_if_exists=True)
for im, lb in zip(imgs, lbls):
......
db.put('%08d' % count, datum.SerializeToString()) Have anyone encountered this problem? |
One interesting thing about using plyvel. When I create DB without using write batch, compute_image_mean tool produces some wrong result. I use the code, listed bellow. It just copies data from one DB to another. import caffe
wb = db.write_batch() # without batch binary mean is wrong
datum = caffe.io.caffe_pb2.Datum()
for k, v in db_in:
wb.put(k,v)
wb.write() # without batch binary mean is wrong Who knows why it happens? |
I am currently creating several million artificial data images in python, all of which I would like stored into LevelDB to be fed through caffe.
At the moment I'm saving all of the images directly to file, and then using 'create_leveldb.sh' to create the LevelDB directories. This creates a problem as I am having to save a couple million images to the HDD.
What I am trying to do is have python directly save the artificial images into LevelDB, and do so without having to save the image to file. Currently, my code is trying to emulate what happens in 'ReadImageToDatum' from io.cpp.
The LevelDB created from my code matches the size (number of leveldb files) of the LevelDB created from convert_imageset.bin; however, when I train caffe on my leveldb directory, both Test#1 and Test#2 get worse over time.
What I am suspecting is that I have missed something when converting the image into a string format, but I may have missed something completely different.
The text was updated successfully, but these errors were encountered: