Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
# Load the models for image and video classification
|
6 |
-
#image_model = pipeline("image-classification", model="Rohit1412/Deepfake", device=0)
|
7 |
video_model = pipeline("video-classification", model="Rohit1412/deepfakerohit2.0")
|
8 |
|
9 |
-
def
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
# Classify the uploaded image
|
19 |
-
predictions = image_model(input_data)
|
20 |
-
return predictions[0]['label'], predictions[0]['score']
|
21 |
|
22 |
# Create Gradio interface
|
23 |
interface = gr.Interface(
|
24 |
-
fn=
|
25 |
-
inputs=gr.
|
26 |
-
outputs=
|
27 |
-
|
28 |
-
|
29 |
-
],
|
30 |
-
title="Image and Video Classification App",
|
31 |
-
description="Upload an image or a video to classify its content. Note: The model is still under training; it may give incorrect outputs."
|
32 |
)
|
33 |
|
34 |
# Launch the interface
|
|
|
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
|