Closed QianyuanLiu closed 6 years ago
Hi,
Firstly, make sure that you did finish the data preparing steps properly.
There may be something wrong of your roidb
. To do further debugging, you print out the value of roidb[i]['image']
before the line, and to see that if the path is valid.
One simple solution maybe deleting the directory of 1.2_cache
and re-generate roidb.
Wish it helps.
@InnerPeace-Wu
Very thankful for your reply !
1)
I recheck the folder /home/XXX/docment/densecap-tensorflow/git/visual_genome/1.2_cache
there are 154797 files in folder train_gt_roidb
and 5001 files in val_gt_roidb
└── visual_genome
├── 1.2
│ ├── test_gt_regions
│ ├── train_gt_regions
│ ├── val_gt_regions
│ └── vocabulary.txt
└── 1.2_cache
├── train_gt_roidb
└── val_gt_roidb
2) I print the value roidb[0]['image']
and get this:
*************************************************************************
im = cv2.imread(roidb[0]['image'])
None
3) I delete the old and re-generate roidb.
XXX@XXX-PC:~/docment/densecap-tensorflow/info$ python read_regions.py --version 1.2 --vg_path
../VG
XXX@XXX-PC:~/docment/densecap-tensorflow/info$ cd ../lib/
XXX@XXX-PC:~/docment/densecap-tensorflow/lib$ python preprocess.py --version 1.2 --path ../VG --output_dir ../git/visual_genome --max_words 10 --limit_ram
split image number: 77398 for split name: train
start loading json files...
0.590941 seconds for loading
train: 100%|███████████████████████████| 108077/108077 [03:08<00:00, 573.80it/s]
processing train set with time: 188.39 seconds
there are 272 invalid bboxes out of 3684063
there are 3 empty phrases after triming
Found 56945 unique word tokens.
Using vocabulary size 10000.
The least frequent word in our vocabulary is 'ruff' and appeared 14 times.
Dumping vocabulary to file: ../git/visual_genome/1.2/vocabulary.txt
Done.
split image number: 5000 for split name: val
start loading json files...
0.452126 seconds for loading
val: 100%|████████████████████████████| 108077/108077 [00:18<00:00, 5692.37it/s]
processing val set with time: 18.99 seconds
there are 14 invalid bboxes out of 237362
there are 0 empty phrases after triming
split image number: 5000 for split name: test
start loading json files...
0.303303 seconds for loading
test: 100%|███████████████████████████| 108077/108077 [00:22<00:00, 4841.91it/s]
processing test set with time: 22.32 seconds
there are 17 invalid bboxes out of 238069
there are 0 empty phrases after triming
when i try to train by typing:
sudo CUDA_VISIBLE_DEVICES="0" bash scripts/dense_cap_train.sh
isual_genome_1.2 res50 resnet_v1_50/res50.ckpt git/visual_genome 1
the same ERROR and same massages are ouput .
Ckpt path: resnet_v1_50/res50.ckpt
Traceback (most recent call last):
File "./tools/train_net.py", line 214, in <module>
main()
File "./tools/train_net.py", line 210, in main
max_iters=args.max_iters)
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/dense_cap/train.py", line 485, in train_net
sw.train_model(sess, max_iters)
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/dense_cap/train.py", line 356, in train_model
blobs = self.data_layer.forward()
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/fast_rcnn/layer.py", line 99, in forward
blobs = self._get_next_minibatch()
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/fast_rcnn/layer.py", line 95, in _get_next_minibatch
return get_minibatch(minibatch_db)
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/fast_rcnn/minibatch.py", line 41, in get_minibatch
im_blob, im_scales, roidb = _get_image_blob(roidb, random_scale_inds)
File "/home/XXXdocment/densecap-tensorflow/tools/../lib/fast_rcnn/minibatch.py", line 101, in _get_image_blob
cfg.TRAIN.MAX_SIZE)
File "/home/XXX/docment/densecap-tensorflow/tools/../lib/utils/blob.py", line 37, in prep_im_for_blob
im = im.astype(np.float32, copy=False)
AttributeError: 'NoneType' object has no attribute 'astype'
Is there my command any wrong ?
other quetion Should i add or modify configurations in root/scripts/dense_cap_config.yml
?
waitting any help :(
thx !
Please add code
print(roidb[0]['image'])
before
im = cv2.imread(roidb[0]['image'])
to see the if the path if valid.
@InnerPeace-Wu
Hello,I add this code :print(roidb[0]['image'])
in here:
for i in xrange(num_images):
**print(roidb[0]['image']) ##**
im = cv2.imread(roidb[i]['image'])
if roidb[i]['flipped']:
im = im[:, ::-1, :]
target_size = cfg.TRAIN.SCALES[scale_inds[i]]
im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
cfg.TRAIN.MAX_SIZE)
im_scales.append(im_scale)
processed_ims.append(im)
and get some output massage like this:
../VG/images/2409215.jpg
and same error info:
AttributeError: 'NoneType' object has no attribute 'astype'
PS: I add this code print (im)
following closely theim = cv2.imread(roidb[0]['image'])
last, print like this:
../VG/images/2409215.jpg
<type 'NoneType'>
None
so, is cv2.read failed ?
The problem seems about your image path, where you used a relative path as ../VG/images/2409215.jpg
(I bet the image id 2409215 is valid, is it?). However you should use a absolute path like /home/user/git/VG/images/id.jpg
.
One way to solve this, you should re-preprocessing data:
Firstly, deleting the directory of 1.2_cache.
Secondly, preprocessing the data with code:
$ cd $ROOT/lib
$ python preprocess.py --version [version] --path [raw_data_path] \
--output_dir [dir] --max_words [max_len] --limit_ram
Note: the [raw_data_path] should be the absolute path of VG
like /home/user/git/VG
. Or you can refer to my example code.
For your case, you can easily address the issue by changing the relative path to the absolute one by changing the line to:
path = '/home/XXX/docment/densecap-tensorflow' + roidb[i]['image'][2:]
im = cv2.imread(path)
Best,
congratulation ! It works ! Thank you ! 👍 👍 👍
Hello, I am a new TF-boy and help some help :) In your tutorial,
when i try to train my model by typing :
sudo CUDA_VISIBLE_DEVICES="0" bash scripts/dense_cap_train.sh visual_genome_1.2 res50 resnet_v1_50/res50.ckpt git/visual_genome 1
I get the ERROR:
There are my sys-info:
ubuntu16.04 GeForce GTX TITAN RAM:8G CUDA:8.0 cudnn:6.0 TF:1.4
I review the code and think the net wasn't feed any data, I locate the issues in this file:
/lib/utils/blob.py
so, i guess the net read nothing from roidb. and how do i fix it ?
PS: the tree of my workspace:
any help will be appreciated. THX : )