Spaces:
Sleeping
Sleeping
Gradio for Video
Browse files
app.py
CHANGED
@@ -1,2 +1,27 @@
|
|
1 |
-
import
|
2 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
video_model = pipeline("video-classification", model="Rohit1412/deepfakerohit2.0")
|
5 |
+
|
6 |
+
def classify_video(video):
|
7 |
+
# Classify the uploaded video and return the results
|
8 |
+
predictions = video_model(video)
|
9 |
+
|
10 |
+
# Create a dictionary of labels and their corresponding scores
|
11 |
+
result = {pred["label"]: pred["score"] for pred in predictions}
|
12 |
+
|
13 |
+
# Return the result dictionary
|
14 |
+
return result
|
15 |
+
|
16 |
+
# Create Gradio interface
|
17 |
+
interface = gr.Interface(
|
18 |
+
fn=classify_video,
|
19 |
+
inputs=gr.Video(label="Upload Video"),
|
20 |
+
outputs=gr.Label(num_top_classes=3, label="Predictions"),
|
21 |
+
title="Video Classification App",
|
22 |
+
description="Upload a video to classify its content."
|
23 |
+
)
|
24 |
+
|
25 |
+
# Launch the interface
|
26 |
+
if __name__ == "__main__":
|
27 |
+
interface.launch(debug=True)
|