Videomae Base Finetuned Ucfcrime Full
V
Videomae Base Finetuned Ucfcrime Full
archit11によって開発
VideoMAEフレームワークを基にUCF-CRIMEデータセットで微調整された動画分類モデルで、破壊行為検出に特化
ダウンロード数 85
リリース時間 : 3/17/2024
モデル概要
このモデルはMCG-NJU/videomae-baseをUCF-CRIMEデータセットで微調整したバージョンで、主に動画内の破壊行為検出と分類タスクに使用されます。
モデル特徴
破壊行為検出
動画内の破壊行為を特異的に識別・分類
VideoMAEフレームワーク採用
効率的なVideoMAE自己教師あり学習フレームワークを使用して事前学習
UCF-CRIMEデータセット微調整
公開されているUCF-CRIMEデータセットで微調整し、異常行動識別に特化
モデル能力
動画分類
破壊行為検出
リアルタイム動画分析
使用事例
セキュリティ監視
公共施設の異常行動検出
公共施設における破壊行為や異常活動を検出
スマートホーム
家庭用セキュリティ監視
家庭用カメラで可能性のある破壊行為を検出
🚀 videomae-base-finetuned-ucfcrime-full2
このモデルは、UCF-CRIMEデータセット上でMCG-NJU/videomae-baseをファインチューニングしたバージョンです。コードはgithubにあります。 評価セットでは以下の結果を達成しています。
- 損失: 2.5014
- 正解率: 0.225
🚀 クイックスタート
このモデルは、UCF-CRIMEデータセット上でvideomae-baseをファインチューニングしたもので、ビデオ分類タスクに使用できます。
✨ 主な機能
- UCF-CRIMEデータセットを使用したファインチューニング
- ビデオ分類タスクに適用可能
📦 インストール
このREADMEには具体的なインストール手順が記載されていないため、このセクションをスキップします。
💻 使用例
基本的な使用法
import av
import torch
import numpy as np
from transformers import AutoImageProcessor, VideoMAEForVideoClassification
from huggingface_hub import hf_hub_download
np.random.seed(0)
def read_video_pyav(container, indices):
'''
Decode the video with PyAV decoder.
Args:
container (`av.container.input.InputContainer`): PyAV container.
indices (`List[int]`): List of frame indices to decode.
Returns:
result (np.ndarray): np array of decoded frames of shape (num_frames, height, width, 3).
'''
frames = []
container.seek(0)
start_index = indices[0]
end_index = indices[-1]
for i, frame in enumerate(container.decode(video=0)):
if i > end_index:
break
if i >= start_index and i in indices:
frames.append(frame)
return np.stack([x.to_ndarray(format="rgb24") for x in frames])
def sample_frame_indices(clip_len, frame_sample_rate, seg_len):
'''
Sample a given number of frame indices from the video.
Args:
clip_len (`int`): Total number of frames to sample.
frame_sample_rate (`int`): Sample every n-th frame.
seg_len (`int`): Maximum allowed index of sample's last frame.
Returns:
indices (`List[int]`): List of sampled frame indices
'''
converted_len = int(clip_len * frame_sample_rate)
end_idx = np.random.randint(converted_len, seg_len)
start_idx = end_idx - converted_len
indices = np.linspace(start_idx, end_idx, num=clip_len)
indices = np.clip(indices, start_idx, end_idx - 1).astype(np.int64)
return indices
# video clip consists of 300 frames (10 seconds at 30 FPS)
file_path = hf_hub_download(
repo_id="nielsr/video-demo", filename="eating_spaghetti.mp4", repo_type="dataset"
)
# use any other video just replace `file_path` with the video path
container = av.open(file_path)
# sample 16 frames
indices = sample_frame_indices(clip_len=16, frame_sample_rate=1, seg_len=container.streams.video[0].frames)
video = read_video_pyav(container, indices)
image_processor = AutoImageProcessor.from_pretrained("archit11/videomae-base-finetuned-ucfcrime-full")
model = VideoMAEForVideoClassification.from_pretrained("archit11/videomae-base-finetuned-ucfcrime-full")
inputs = image_processor(list(video), return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
# model predicts one of the 13 ucf-crime classes
predicted_label = logits.argmax(-1).item()
print(model.config.id2label[predicted_label])
高度な使用法
import cv2
import torch
import numpy as np
from transformers import AutoImageProcessor, VideoMAEForVideoClassification
np.random.seed(0)
def preprocess_frames(frames, image_processor):
inputs = image_processor(frames, return_tensors="pt")
inputs = {k: v.to(device) for k, v in inputs.items()} # Move tensors to GPU
return inputs
# Initialize the video capture object, replace ip addr with the local ip of your phone (will be shown in the ipwebcam app)
cap = cv2.VideoCapture('http://192.168.229.98:8080/video')
# Set the frame size (optional)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
image_processor = AutoImageProcessor.from_pretrained("archit11/videomae-base-finetuned-ucfcrime-full")
model = VideoMAEForVideoClassification.from_pretrained("archit11/videomae-base-finetuned-ucfcrime-full")
# Move the model to GPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
frame_buffer = []
buffer_size = 16
previous_labels = []
top_confidences = [] # Initialize top_confidences
while True:
ret, frame = cap.read()
if not ret:
print("Failed to capture frame")
break
# Add the current frame to the buffer
frame_buffer.append(frame)
# Check if we have enough frames for inference
if len(frame_buffer) >= buffer_size:
# Preprocess the frames
inputs = preprocess_frames(frame_buffer, image_processor)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
# Get the top 3 predicted labels and their confidence scores
top_k = 3
probs = torch.softmax(logits, dim=-1)
top_probs, top_indices = torch.topk(probs, top_k)
top_labels = [model.config.id2label[idx.item()] for idx in top_indices[0]]
top_confidences = top_probs[0].tolist() # Update top_confidences
# Check if the predicted labels are different from the previous labels
if top_labels != previous_labels:
previous_labels = top_labels
print("Predicted class:", top_labels[0]) # Print the predicted class for debugging
# Clear the frame buffer and continue from the next frame
frame_buffer.clear()
# Display the predicted labels and confidence scores on the frame
for i, (label, confidence) in enumerate(zip(previous_labels, top_confidences)):
label_text = f"{label}: {confidence:.2f}"
cv2.putText(frame, label_text, (10, 30 + i * 30), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 2)
# Display the resulting frame
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release everything when done
cap.release()
cv2.destroyAllWindows()
📚 ドキュメント
トレーニング手順
トレーニングハイパーパラメータ
トレーニング中に以下のハイパーパラメータが使用されました。
- 学習率: 5e-05
- トレーニングバッチサイズ: 8
- 評価バッチサイズ: 8
- シード: 42
- オプティマイザ: Adam (betas=(0.9,0.999), epsilon=1e-08)
- 学習率スケジューラタイプ: linear
- 学習率スケジューラウォームアップ比率: 0.1
- トレーニングステップ: 700
トレーニング結果
トレーニング損失 | エポック | ステップ | 検証損失 | 正解率 |
---|---|---|---|---|
2.5836 | 0.13 | 88 | 2.4944 | 0.2080 |
2.3212 | 1.13 | 176 | 2.5855 | 0.1773 |
2.2333 | 2.13 | 264 | 2.6270 | 0.1046 |
1.985 | 3.13 | 352 | 2.4058 | 0.2109 |
2.194 | 4.13 | 440 | 2.3654 | 0.2235 |
1.9796 | 5.13 | 528 | 2.2609 | 0.2235 |
1.8786 | 6.13 | 616 | 2.2725 | 0.2341 |
1.71 | 7.12 | 700 | 2.2228 | 0.2226 |
フレームワークバージョン
- Transformers 4.38.1
- Pytorch 2.1.2
- Datasets 2.1.0
- Tokenizers 0.15.2
🔧 技術詳細
このREADMEには具体的な技術詳細が記載されていないため、このセクションをスキップします。
📄 ライセンス
このモデルはCC BY-NC 4.0ライセンスの下で提供されています。
Timesformer Base Finetuned K400
TimeSformerはKinetics-400データセットで事前学習されたビデオ分類モデルで、時空間アテンションメカニズムを用いてビデオ理解を実現します。
動画処理
Transformers

T
facebook
108.61k
33
Vivit B 16x2 Kinetics400
MIT
ViViTはビジョントランスフォーマー(ViT)をビデオ処理向けに拡張したもので、特にビデオ分類タスクに適しています。
動画処理
Transformers

V
google
56.94k
32
Animatediff Motion Lora Zoom In
動的LoRAsは、ズーム、パン、チルト、回転などの特定の種類のモーション効果をアニメーションに追加できます。
動画処理
A
guoyww
51.43k
8
Videomae Base
VideoMAEはマスクオートエンコーダ(MAE)に基づくビデオ自己教師あり事前学習モデルで、マスクされたビデオブロックのピクセル値を予測することでビデオ内部表現を学習します。
動画処理
Transformers

V
MCG-NJU
48.66k
45
Dfot
MIT
任意の数のコンテキストフレームから高品質なビデオを生成できる新しいビデオ拡散モデル
動画処理
D
kiwhansong
47.19k
6
Videomae Base Finetuned Kinetics
VideoMAEはマスクオートエンコーダ(MAE)に基づく動画自己教師あり事前学習モデルで、Kinetics-400データセットでファインチューニング後、動画分類タスクに使用可能です。
動画処理
Transformers

V
MCG-NJU
44.91k
34
Mochi 1 Preview
Apache-2.0
Genmoが開発した高品質ビデオ生成モデルで、優れた動き表現力と正確なプロンプト追従能力を備えています
動画処理 英語
M
genmo
27.13k
1,216
Animatediff Motion Lora Zoom Out
動的LoRAsはアニメーションに特定のタイプの動き効果を追加できます
動画処理
A
guoyww
11.43k
5
Ppo SpaceInvadersNoFrameskip V4
これはPPOアルゴリズムに基づく強化学習エージェントで、SpaceInvadersNoFrameskip-v4ゲーム環境でのトレーニングとプレイに特化しています。
動画処理
P
sb3
8,999
0
Stable Video Diffusion Img2vid Xt 1 1
その他
Stable Video Diffusion (SVD) 1.1 は拡散モデルベースの画像から動画への変換ツールで、静止画像を条件フレームとして短い動画クリップを生成できます。
動画処理
S
vdo
8,560
28
おすすめAIモデル
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers 複数言語対応

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98