tadax / m2det Goto Github PK
View Code? Open in Web Editor NEWM2Det implementation using TensorFlow
License: MIT License
M2Det implementation using TensorFlow
License: MIT License
I insert the code :" parser.add_argument('--num_boxes', type=int, default=196560) # (128x128+64x64+32x32+16x16+8x8+4x4)x9=196560
parser.add_argument('--shapes', type=int, nargs='+', default=[128, 64, 32, 16, 8, 4]) # for 1024x1024" in the evalution.py,
the used the command:
python evaluate.py --image_dir trace_damge_detect_dataset/JPEGImages/ --label_dir mscoco/labels/ --model_path weights/checkpoint
but, I meet the problem:
DataLossError (see above for traceback): Unable to open table file weights/checkpoint: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
[[Node: save/RestoreV2/_301 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_306_save/RestoreV2", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]
please help me ,thanks! please~!
I run the command:
python evaluate.py --image_dir trace_damge_detect_dataset/JPEGImages --label_dir trace_damge_detect_dataset/annotations/ --model_path weights/variables
/home/yh/.conda/envs/yh/lib/python3.6/site-packages/numpy/core/fromnumeric.py:2957: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/home/yh/.conda/envs/yh/lib/python3.6/site-packages/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
[email protected]: nan
def assign_boxes(boxes, priors, num_classes, threshold=0.5):
num_classes += 1 # add background class
assignment = np.zeros((len(priors), 4 + num_classes + 1))
assignment[:, 4] = 1.0 # background
encoded_boxes = np.apply_along_axis(encode_box, 1, boxes[:, :4], priors, threshold)
encoded_boxes = encoded_boxes.reshape(-1, len(priors), 5)
best_iou = encoded_boxes[:, :, -1].max(axis=0)
best_iou_idx = encoded_boxes[:, :, -1].argmax(axis=0)
I think the axis should be 1 , not 0. it that right? why?
best_iou_mask = best_iou > 0 # judge by iou between prior and bbox
best_iou_idx = best_iou_idx[best_iou_mask]
assign_num = len(best_iou_idx)
encoded_boxes = encoded_boxes[:, best_iou_mask, :]
assignment[:, :4][best_iou_mask] = encoded_boxes[best_iou_idx, np.arange(assign_num), :4]
assignment[:, 4][best_iou_mask] = 0 # background
assignment[:, 5:-1][best_iou_mask] = boxes[best_iou_idx, 4:]
assignment[:, -1][best_iou_mask] = 1 # objectness
return assignment
Have you tested the effect of your model? How is the mAP
for code about SFAM as bellowing, seems fc1 is sigmoid and fc2 is relu, while the order in author' code is inverse?
with tf.variable_scope('SFAM'):
for i in range(self.scales):
feature = tf.concat([outs[j][i] for j in range(self.levels)], axis=3)
attention = tf.reduce_mean(feature, axis=[1, 2], keepdims=True)
attention = tf.layers.dense(inputs=feature, units=64,
activation=tf.nn.sigmoid, name='fc1_{}'.format(i+1))
attention = tf.layers.dense(inputs=attention, units=1024,
activation=tf.nn.relu, name='fc2_{}'.format(i+1))
feature = feature * attention
features.insert(0, feature)
Hi, while reading your code, I found unnecessary line in m2det.py.
(Commint ID: f0decfe)
In m2det.py line 52.
attention = tf.reduce_mean(feature, axis=[1, 2], keepdims=True)
attention = tf.layers.dense(inputs=feature, units=64,
activation=tf.nn.sigmoid, name='fc1_{}'.format(i+1))
attention = tf.layers.dense(inputs=attention, units=1024,
activation=tf.nn.relu, name='fc2_{}'.format(i+1))
Line 52 have no meaning because attention
is re-assigned in line 53 before using it.
As I understand it, reduce_mean is for averaging pooling.
It seems to be same with line in below link(which is from author's implementation with pytorch).
https://github.com/qijiezhao/M2Det/blob/579c0f7b46b9b0a5bd301e92823c4ab115cfaccc/layers/senet.py#L98
So, Should line 53 be modified like below?
attention = tf.reduce_mean(feature, axis=[1, 2], keepdims=True)
attention = tf.layers.dense(inputs=attention, units=64,
activation=tf.nn.sigmoid, name='fc1_{}'.format(i+1))
attention = tf.layers.dense(inputs=attention, units=1024,
activation=tf.nn.relu, name='fc2_{}'.format(i+1))
Hello,I want to ask you,can this model train the Pascal VOC datasets?
i meet the problem, when I set --input_size 1024 and --num_boxes 196560,
in the train progress , it has the error : can't send the size [? 196560,20] to [8,19251,20],
I find all files to locate the 19251, but I can't find it
please help me, thanks!
I run the command as: python demo.py --inputs fatigue_block_37.jpg
and modifed the demo.py about the lines:
parser.add_argument('--input_size', type=int, default=1024)
parser.add_argument('--num_classes', type=int, default=14)
Traceback (most recent call last):
File "demo.py", line 56, in
main(parser.parse_args())
File "demo.py", line 41, in main
results = det.detect(img)
File "/data/yh/proj/m2det/utils/detector.py", line 74, in detect
boxes = self.decode_boxes(outs[:, :4])
File "/data/yh/proj/m2det/utils/detector.py", line 37, in decode_boxes
decode_bbox_center_x = boxes[:, 0] * 0.1 * prior_width # variance0
ValueError: operands could not be broadcast together with shapes (196560,) (19215,)
Hi, while reading yours code, I don't understand the mean of "num_priors".
Can you tell me the answer?
Thank you
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.