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

video_path is what ? #4510

Closed
ucas010 opened this issue Apr 1, 2020 · 10 comments
Closed

video_path is what ? #4510

ucas010 opened this issue Apr 1, 2020 · 10 comments
Assignees

Comments

@ucas010
Copy link

ucas010 commented Apr 1, 2020

hi,dear
in the predict.py,
what's the meaning ?

    parser.add_argument(
        '--save_dir',
        type=str,
        default=os.path.join('data', 'predict_results'),
        help='directory to store results')
    parser.add_argument(
        '--video_path',
        type=str,
        default=None,
        help='directory to store results')

video_path is the video what I want to test/infer ?

thx

@ucas010
Copy link
Author

ucas010 commented Apr 1, 2020

but no,
when I set the para
default='D:/python36/new/dyrandom/mvideo_0.mp4',
also has the same problem

Traceback (most recent call last):
  File "D:\python36\new\rcdnn\image\predict.py", line 181, in <module>
    infer(args)
  File "D:\python36\new\rcdnn\image\predict.py", line 103, in infer
    infer_reader = get_reader(args.model_name.upper(), 'infer', infer_config)
  File "D:\python36\new\rcdnn\image\reader\reader_utils.py", line 67, in get_reader
    return reader_model.create_reader()
  File "D:\python36\new\rcdnn\image\reader\feature_reader.py", line 38, in create_reader
    fl = open(self.filelist).readlines()
FileNotFoundError: [Errno 2] No such file or directory: './data/dataset/youtube8m/infer.list'

So what's the para 's meaning ?
thx

@heavengate
Copy link
Contributor

您好,哪个模型呢

@ucas010
Copy link
Author

ucas010 commented Apr 2, 2020

@heavengate
NeXtVLAD

@SunGaofeng
Copy link
Contributor

the --video_path argument is designed to point to the video file to be processed, it can be 'D:/python36/new/dyrandom/mvideo_0.mp4'.

However, only models such as TSN, TSM, StNet and NONLOCAL in PaddleVideo support processing a video file of MP4 or other format.
The model NeXtVLAD does not support processing a video file since it should take feature data as input.
If you want to predict by NeXtVLAD, please transfer the origin video file into feature data first.

@ucas010
Copy link
Author

ucas010 commented Apr 2, 2020

@SunGaofeng
thx
So could you tell me which is the API of the feature input to the model,
or just tell me what's the data format in
./data/dataset/youtube8m/infer.list
thanks a lot

@SunGaofeng
Copy link
Contributor

SunGaofeng commented Apr 2, 2020

@SunGaofeng
thx
So could you tell me which is the API of the feature input to the model,
or just tell me what's the data format in
./data/dataset/youtube8m/infer.list
thanks a lot

This is similar to those used in the training dataset, where all the feature data are transformed from the Youtube-8M original data and stored in the pickle format. For details, you can refer to this document https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/video/data/dataset#Youtube-8M数据集

If you use your own video file, you can use a pertained model to extract the rgb/audio feature data for each frame. For each video, the data format is a dictionary as:

video_data = {'video': video_id_string, 
                            'nframes':number_of_frames_int, 
                           'feature': extracted_rgb_feature_numpy, 
                           'audio': extracted_audio_feature_numpy}

./data/dataset/youtube8m/infer.list assumes that you store your data in pickle files. Each line of infer.list is the path of a pickle file. Each pickle file may store one or more video data, which is a list as [video_data1, video_data2, ...]

@ucas010
Copy link
Author

ucas010 commented Apr 2, 2020

@SunGaofeng
thanks for your kind help,
it's important to inference with the pretrained model.

@ucas010
Copy link
Author

ucas010 commented Apr 2, 2020

some other question
if I only have one frame image, several frame audio feature,
how to set the 'nframes'?
or should I separate the them, then got each of theirs inference ?just as follows
image
I want to get the feature before Concat Op.
but when I see the codes,I do not know how to deal with it.

    def create_reader(self):
        fl = open(self.filelist).readlines()
        fl = [line.strip() for line in fl if line.strip() != '']

        def reader():
            batch_out = []
            for filepath in fl:
                print(python_ver)
                if python_ver < (3, 0):
                    data = pickle.load(open(filepath, 'rb'))
                else:
                    data = pickle.load(open(filepath, 'rb'), encoding='bytes')
                indexes = list(range(len(data)))

                for i in indexes:
                    record = data[i]
                    nframes = record[b'nframes']
                    rgb = record[b'feature'].astype(float)
                    audio = record[b'audio'].astype(float)
                    video = record[b'video']

                    rgb = rgb[0:nframes, :]
                    audio = audio[0:nframes, :]

                    batch_out.append((rgb, audio, video))
                    if len(batch_out) == self.batch_size:
                        yield batch_out
                        batch_out = []

        return reader

So could U please help me ?
thx

@SunGaofeng
Copy link
Contributor

SunGaofeng commented Apr 3, 2020

image

If you have different frame numbers for audio and video, just set different 'nframes' value for them.
The feature before concat if sequence pooled, so you can concat audio and video feature even through they have different frames.

vlad = fluid.layers.sequence_pool(vlad, 'sum')

image

@ucas010
Copy link
Author

ucas010 commented Apr 3, 2020

@SunGaofeng
thanks for your kind help
Now will close the issue.

@ucas010 ucas010 closed this as completed Apr 3, 2020
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