nam_nguyenhoai_AI
commited on
Commit
·
fac95bf
1
Parent(s):
b0a48de
update application file
Browse files- __pycache__/algorithm.cpython-38.pyc +0 -0
- __pycache__/utils.cpython-38.pyc +0 -0
- app.py +0 -3
- requirements.txt +4 -2
- utils.py +0 -9
__pycache__/algorithm.cpython-38.pyc
ADDED
|
Binary file (1.92 kB). View file
|
|
|
__pycache__/utils.cpython-38.pyc
ADDED
|
Binary file (2.32 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import os
|
| 4 |
-
import spaces
|
| 5 |
import tempfile
|
| 6 |
from torchvision import transforms
|
| 7 |
from torchvision.transforms import Compose
|
|
@@ -9,12 +8,10 @@ import torch
|
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
import torch.nn.functional as F
|
| 12 |
-
from pytorchvideo.transforms.functional import predict_depth
|
| 13 |
from transformers import pipeline, TimesformerModel, VideoMAEImageProcessor
|
| 14 |
from utils import *
|
| 15 |
from algorithm import *
|
| 16 |
|
| 17 |
-
@spaces.GPU
|
| 18 |
def make_video(video_path, outdir='./summarized_video',encoder='Kmeans'):
|
| 19 |
if encoder not in ["Kmeans", "Sum of Squared Difference 01", "Sum of Squared Difference 02"]:
|
| 20 |
encoder = "Kmeans"
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import os
|
|
|
|
| 4 |
import tempfile
|
| 5 |
from torchvision import transforms
|
| 6 |
from torchvision.transforms import Compose
|
|
|
|
| 8 |
import numpy as np
|
| 9 |
from PIL import Image
|
| 10 |
import torch.nn.functional as F
|
|
|
|
| 11 |
from transformers import pipeline, TimesformerModel, VideoMAEImageProcessor
|
| 12 |
from utils import *
|
| 13 |
from algorithm import *
|
| 14 |
|
|
|
|
| 15 |
def make_video(video_path, outdir='./summarized_video',encoder='Kmeans'):
|
| 16 |
if encoder not in ["Kmeans", "Sum of Squared Difference 01", "Sum of Squared Difference 02"]:
|
| 17 |
encoder = "Kmeans"
|
requirements.txt
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
gradio_imageslider
|
| 2 |
-
gradio==4.
|
| 3 |
torch
|
| 4 |
pillow
|
| 5 |
torchvision
|
| 6 |
opencv-python
|
| 7 |
-
huggingface_hub
|
|
|
|
|
|
|
|
|
| 1 |
gradio_imageslider
|
| 2 |
+
gradio==4.29.0
|
| 3 |
torch
|
| 4 |
pillow
|
| 5 |
torchvision
|
| 6 |
opencv-python
|
| 7 |
+
huggingface_hub
|
| 8 |
+
pytorchvideo==0.1.5
|
| 9 |
+
spaces
|
utils.py
CHANGED
|
@@ -52,15 +52,6 @@ def to_video(selected_frames, frames, output_path, video_fps):
|
|
| 52 |
video_writer.release()
|
| 53 |
print("Completed summarizing the video (wait for a moment to load).")
|
| 54 |
|
| 55 |
-
def to_txt(selected_frames, output_path, clip_sample_rate):
|
| 56 |
-
# Write the selected frames to a txt file
|
| 57 |
-
|
| 58 |
-
with open(output_path, "w") as file:
|
| 59 |
-
for item in selected_frames:
|
| 60 |
-
file.write(str(item) + "\n")
|
| 61 |
-
|
| 62 |
-
print("Completed summarizing the txt (wait for a moment to load).")
|
| 63 |
-
|
| 64 |
def load_model():
|
| 65 |
try:
|
| 66 |
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
|
|
| 52 |
video_writer.release()
|
| 53 |
print("Completed summarizing the video (wait for a moment to load).")
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
def load_model():
|
| 56 |
try:
|
| 57 |
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|