Spaces:
Runtime error
Runtime error
from transformers import VideoMAEImageProcessor, VideoMAEForVideoClassification, pipeline | |
import gradio as gr | |
import magic | |
pipe = pipeline("video-classification", model="anirudhmu/videomae-base-finetuned-soccer-action-recognition") | |
def predict_video(file_path): | |
# Check the file type | |
mime = magic.Magic(mime=True) | |
file_type = mime.from_file(file_path) | |
if not file_type.startswith('video/'): | |
return "Invalid file type. Please upload a valid video." | |
# Run inference | |
results = pipe(file_path) | |
label_to_score = {result["label"]: result["score"] for result in results} | |
return str(label_to_score) | |
iface = gr.Interface(fn=predict_video, inputs="video", outputs="text") | |
iface.launch() |