mchengny / RWF2000-Video-Database-for-Violence-Detection

A large scale video database for violence detection, which has 2,000 video clips containing violent or non-violent behaviours.
396 stars 85 forks source link

how run project #15

Open herokarimpoor opened 2 years ago

herokarimpoor commented 2 years ago

hi i use Intro pre-trained model and ,

I run the project with the following code, but the answers are in this range. What do you mean by these answers? And which one indicates violence? def video_generator(video_path):

"""
This function returns the video frames as a generator.
"""

cap = cv2.VideoCapture(video_path)
counter = 0

frames = []
while cap.isOpened():

if counter == 64:

frames = []

counter = 0

    success, frame = cap.read()

    if not success:
        break

    # frame = cv2.resize(frame, dsize=(300, 200))

    counter += 1
    frames.append(frame)

    if counter == 64:
        yield frames
        frames = []
        counter = 0

cap.release()

video_path = './1.mp4' vid_gen = video_generator(video_path) frames = Video2Npy(file_path='2.mp4') for i in range(int(790/64)): preds = model.predict(np.expand_dims(frames[64 i: 64 (i + 1)], axis=0)) print('prediction of', 64 i, 'to', 64 (i + 1) - 1, 'is ', preds, '\n')

answre: prediction of 0 to 63 is [[0.9811358 0.0188642]]

prediction of 64 to 127 is [[9.9985802e-01 1.4190395e-04]]

prediction of 128 to 191 is [[9.9957794e-01 4.2205575e-04]]

prediction of 192 to 255 is [[0.78644943 0.21355057]]

prediction of 256 to 319 is [[0.74419075 0.25580925]]

prediction of 320 to 383 is [[0.8570261 0.14297388]]

prediction of 384 to 447 is [[0.8125017 0.18749826]]

prediction of 448 to 511 is [[0.8385145 0.16148551]]

prediction of 512 to 575 is [[9.9999928e-01 7.6247477e-07]]

*** Please, you can put the execution code like a demo in the github?

***** For long films, I do not know which frames detect violence ????????????

verages commented 2 years ago

The first class is fighting, the second is normal.The program analyzes 64 frames at a time and outputs the result once. At the same time, the result adopts the softmax result, so you can add judgment to confirm the current state and process the image and save it as a video.it's not hard

verages commented 2 years ago

The first class is fighting, the second is normal.The program analyzes 64 frames at a time and outputs the result once. At the same time, the result adopts the softmax result, so you can add judgment to confirm the current state and process the image and save it as a video.it's not hard

The first class is fighting, the second is normal.The program analyzes 64 frames at a time and outputs the result once. At the same time, the result adopts the softmax result, so you can add judgment to confirm the current state and process the image and save it as a video.it's not hard. But there is a problem, the optical flow estimation may not be accurate, and the actual detection results are not satisfactory.