Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import load_learner, Path
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Function to perform sequence prediction
|
| 6 |
+
def sequence_prediction(video_path):
|
| 7 |
+
# Load the Fastai model inside the function
|
| 8 |
+
modelx = load_learner('r3d_apparel.pkl')
|
| 9 |
+
result = modelx.predict(Path(video_path))
|
| 10 |
+
return result[0]
|
| 11 |
+
|
| 12 |
+
# Gradio interface
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=sequence_prediction,
|
| 15 |
+
inputs=gr.Video(label="Upload a video file"),
|
| 16 |
+
outputs="text",
|
| 17 |
+
live=True # Set live to True to get real-time updates
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Launch the Gradio app
|
| 21 |
+
iface.launch()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|