Spaces:
Runtime error
Runtime error
Commit
·
f7cf168
1
Parent(s):
ac61cde
1.0.1
Browse files- app.py +43 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModel, AutoProcessor
|
3 |
+
import torch
|
4 |
+
import cv2
|
5 |
+
|
6 |
+
# Load the model and processor from Hugging Face Hub
|
7 |
+
model_name = "OpenGVLab/InternVideo2_5_Chat_8B" # Replace with the correct model name
|
8 |
+
model = AutoModel.from_pretrained(model_name,trust_remote_code=True)
|
9 |
+
processor = AutoProcessor.from_pretrained(model_name,trust_remote_code=True)
|
10 |
+
|
11 |
+
def predict(video_path):
|
12 |
+
# Load the video
|
13 |
+
video = cv2.VideoCapture(video_path)
|
14 |
+
frames = []
|
15 |
+
while True:
|
16 |
+
ret, frame = video.read()
|
17 |
+
if not ret:
|
18 |
+
break
|
19 |
+
frames.append(frame)
|
20 |
+
video.release()
|
21 |
+
|
22 |
+
# Preprocess the frames
|
23 |
+
inputs = processor(frames, return_tensors="pt")
|
24 |
+
|
25 |
+
# Perform inference
|
26 |
+
with torch.no_grad():
|
27 |
+
outputs = model(**inputs)
|
28 |
+
|
29 |
+
# Process the outputs (replace this with your actual logic)
|
30 |
+
prediction = "Hello (Example Prediction)"
|
31 |
+
return prediction
|
32 |
+
|
33 |
+
# Create Gradio interface
|
34 |
+
iface = gr.Interface(
|
35 |
+
fn=predict,
|
36 |
+
inputs=gr.Video(label="Upload Video"),
|
37 |
+
outputs=gr.Textbox(label="Prediction"),
|
38 |
+
title="Indian Sign Language Recognition",
|
39 |
+
description="Upload a video to recognize Indian Sign Language gestures.",
|
40 |
+
)
|
41 |
+
|
42 |
+
# Launch the interface
|
43 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
torchvision
|
4 |
+
opencv-python
|
5 |
+
gradio
|