File size: 1,237 Bytes
f7cf168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
from transformers import AutoModel, AutoProcessor
import torch
import cv2

# Load the model and processor from Hugging Face Hub
model_name = "OpenGVLab/InternVideo2_5_Chat_8B"  # Replace with the correct model name
model = AutoModel.from_pretrained(model_name,trust_remote_code=True)
processor = AutoProcessor.from_pretrained(model_name,trust_remote_code=True)

def predict(video_path):
    # Load the video
    video = cv2.VideoCapture(video_path)
    frames = []
    while True:
        ret, frame = video.read()
        if not ret:
            break
        frames.append(frame)
    video.release()

    # Preprocess the frames
    inputs = processor(frames, return_tensors="pt")

    # Perform inference
    with torch.no_grad():
        outputs = model(**inputs)

    # Process the outputs (replace this with your actual logic)
    prediction = "Hello (Example Prediction)"
    return prediction

# Create Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs=gr.Video(label="Upload Video"),
    outputs=gr.Textbox(label="Prediction"),
    title="Indian Sign Language Recognition",
    description="Upload a video to recognize Indian Sign Language gestures.",
)

# Launch the interface
iface.launch()