Skip to content
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

LMDB file creation #18

Closed
pranayamhatre175 opened this issue Apr 20, 2017 · 5 comments
Closed

LMDB file creation #18

pranayamhatre175 opened this issue Apr 20, 2017 · 5 comments

Comments

@pranayamhatre175
Copy link

Hi...I am new in caffe and i just know basic working of caffe. For single character recognition we just provide image path and label in train.txt and val.txt file. Can anyone please tell me in Textboxes what is format of train.txt and val.txt for creating lmdb?

My train.txt file contains image path and annotation file path for coco dataset is it right ? and how can we open lmdb file which contains annotations ?

I used following code for reading LMDB file

import caffe
import lmdb
import numpy as np
import cv2
import matplotlib.pyplot as plt
from caffe.proto import caffe_pb2

lmdb_file='/home/arha/workarea/ocr_project/cocotext/data/lmdb/coco_val_lmdb'
lmdb_env = lmdb.open(lmdb_file)
lmdb_txn = lmdb_env.begin()
lmdb_cursor = lmdb_txn.cursor()

datum = caffe_pb2.Datum()
for key, value in lmdb_cursor:
datum.ParseFromString(value)

label = datum.label
print 'label=',label
data = caffe.io.datum_to_array(datum)
print data.shape
print 'data=',data
image = np.transpose(data, (1,2,0))
cv2.imshow('cv2', image)
cv2.waitKey(0)
print('{},{}'.format(key, label))
And It is giving output as follow

label= 0
(0, 0, 0)
data= []
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/arha/softwares/opencv-2.4.13/modules/highgui/src/window.cpp, line 261
Traceback (most recent call last):
File "lm.py", line 28, in
cv2.imshow('cv2', image)
cv2.error: /home/arha/softwares/opencv-2.4.13/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow

Please clear my doubts.

Thank you

@rremani
Copy link

rremani commented Apr 26, 2017

Hi,
if you are interested in checking that if your created lmdb is fine for training, you can use ssd.ipynb in examples folder, this can can show if your annotations are right top on your target.

@pranayamhatre175
Copy link
Author

Hi,
Thank you so much @rremani
I can now check whether the created LMDB file is fine for training or not. Your solution works for me.

@pankajkumar
Copy link

Hi Guys,
Can you give details about how to check created LMDB file using ssd.ipynb ?

@rremani
Copy link

rremani commented Apr 27, 2017

Hi Pankaj,
Just run step by step ssd.ipynb cells and you'll understand.
@pranayamhatre175 cool you got it, you can close the issue.

@pankajkumar
Copy link

Hi @rremani ,
I have tried to run ssh.ipynb file step by step but I am getting attached image in step 4 (annotated datum) and similar image in step 9. Looks like something is wrong. Can you suggest what is wrong?

index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants