- Updated model selection in image-to-image, mask generation, object detection, video classification, zero-shot image classification, zero-shot object detection, document question answering, feature extraction, image-to-text, image-text-to-text, visual question answering, conversational, fill mask, question answering, sentence similarity, table question answering, zero-shot classification, text classification, text generation, and token classification pipelines to use a default string instead of a model list. - Removed unused keypoint detection, summarization, text2text generation, and translation pipelines. - Added utility nodes for type conversion: IntToString, StringToInt, FloatToString, and StringToFloat. - Updated all pipeline calls to include trust_remote_code=True for enhanced security. - Improved requirements by adding timm and opencv-python for better functionality.
24 lines
870 B
Python
24 lines
870 B
Python
from transformers import pipeline as hf_pipeline
|
|
import json
|
|
|
|
class VideoClassificationPipeline:
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"video_path": ("STRING", {"default": ""}),
|
|
"model_name": ("STRING", {"default": "MCG-NJU/videomae-base-finetuned-kinetics"}),
|
|
"top_k": ("INT", {"default": 5, "min": 1, "max": 20}),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("STRING",)
|
|
RETURN_NAMES = ("results_json",)
|
|
FUNCTION = "run_video_classification"
|
|
CATEGORY = "Transformers/VideoClassification"
|
|
|
|
def run_video_classification(self, video_path, model_name, top_k):
|
|
pipe = hf_pipeline("video-classification", model=model_name, trust_remote_code=True)
|
|
result = pipe(video_path, top_k=top_k)
|
|
return (json.dumps(result, indent=2, default=str),)
|