Closed kaisark closed 5 years ago
Seems like it has trouble processing the frame. Could you run it again with the latest checkout, I have updated the scripts.
I changed the default behaviour of vis_one_image() in vis.py. Instead of writing separate image files to disk, it creates a single image file by overlaying inferred contours on the input video frame.
@kaisark Did you solve your problem with the latest script?
@trrahul With you latest script, I still met the same issue on "no attribute 'astype'" as Kaisar's. Could you please check it again? Thanks a lot!
Could you post the traceback with the frame number?
|Processing Frame 273/274
-Frame read in 0.002s
|Processing Frame 274/274
-Frame read in 0.002s
| Inference time: 0.758s
| im_detect_bbox: 0.363s
| im_detect_body_uv: 0.395s
| misc_bbox: 0.000s
-Visualized in 0.458s
-Output file wrote in 0.090s
|Processing Frame 275/274
-Frame read in 0.030s
|Processing Frame 276/274
-Frame read in 0.028s
Traceback (most recent call last):
File "tools/infer_vid.py", line 146, in
You see there are only 274 frames in total, but the loop continues past the end of the file and pass the invalid frame to the model. That is why this error occurs.
Modify line 101 in infer_vid.py to
while (cap.isOpened() and grab < total_frames ):
Logic needs to be added to check if a frame was returned in the loop...
CURRENT CODE: while (cap.isOpened()): print( "|Processing Frame {0}/{1} ".format(grab,total_frames)) grab += 1 captime = time.time() ret_val, im = cap.read()
SOLUTION: while True: (grabbed, frame) = cap.read()
if not grabbed:
break
@kaisark @trrahul Thanks for the reply!
@trrahul I wonder what is your inference time for each frame? By ResNet50, mine is around 0.8s (0.3s for bbox + 0.5s for body uv), which is too large to achieve a high-frame-rate detection. Do I have to get the VRAM?
My machine config is as follows: +-----------------------------------------------------------------------------+ | NVIDIA-SMI 390.30 Driver Version: 390.30 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 Tesla K80 Off | 00000000:00:04.0 Off | 0 | | N/A 34C P8 26W / 149W | 15MiB / 11441MiB | 0% Default | +-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1404 G /usr/lib/xorg/Xorg 15MiB | +-----------------------------------------------------------------------------+
I found that the inference time largely depends on the performance of the GPU and the frame resolution of the input. As your log indicates, you have 11 GB of memory and it is enough to load the models but I'm not sure about the GPU's clock speed. Try running it with resized images, you should see inference in less time.
Install gpustat from here. https://github.com/wookayin/gpustat
Run it using watch --color -n1.0 gpustat --color
before you run the inference. Monitor the GPU activity. Ideally the GPU should be at above 80% utilisation.
I ran into a run-time error. The script seemed to process most of the video file. I wonder if it errored on the last frame???
I did have a question regarding the vis.py file. I placed vis.py in the detectron utils under densepose. I saw there was already a vis.py file there (I backed it up). Did you add functions or are you overriding them as well? Is there any lost functionality using your vis.py???
System: Ubuntu 16 Python2 OpenCV 3.3
(dl4cvcaffepy27) ubuntu@ip-172-31-0-76:~/densepose$ python2 tools/infer_simple_video.py --cfg configs/DensePose_ResNet50_FPN_s1x-e2e.yaml --output-dir DensePoseData/infer_out/ --wts https://s3.amazonaws.com/densepose/DensePose_ResNet50_FPN_s1x-e2e.pkl .
INFO infer_simple_video.py: 132: Inference time: 0.997s INFO infer_simple_video.py: 134: | im_detect_bbox: 0.412s INFO infer_simple_video.py: 134: | im_detect_body_uv: 0.584s INFO infer_simple_video.py: 134: | misc_bbox: 0.000s processing image processing image INFO infer_simple_video.py: 132: Inference time: 1.084s INFO infer_simple_video.py: 134: | im_detect_bbox: 0.403s INFO infer_simple_video.py: 134: | im_detect_body_uv: 0.680s INFO infer_simple_video.py: 134: | misc_bbox: 0.000s processing image processing image Traceback (most recent call last): File "tools/infer_simple_video.py", line 167, in
main(args)
File "tools/infer_simple_video.py", line 130, in main
model, im, None, timers=timers
File "/home/ubuntu/densepose/detectron/core/test.py", line 58, in im_detect_all
model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals
File "/home/ubuntu/densepose/detectron/core/test.py", line 137, in im_detect_bbox
inputs, im_scale = _get_blobs(im, boxes, target_scale, target_max_size)
File "/home/ubuntu/densepose/detectron/core/test.py", line 1028, in _get_blobs
blob_utils.get_image_blob(im, target_scale, target_max_size)
File "/home/ubuntu/densepose/detectron/utils/blob.py", line 44, in get_image_blob
im, cfg.PIXEL_MEANS, target_scale, target_max_size
File "/home/ubuntu/densepose/detectron/utils/blob.py", line 100, in prep_im_for_blob
im = im.astype(np.float32, copy=False)
AttributeError: 'NoneType' object has no attribute 'astype'