Spaces:
Runtime error
Runtime error
autism_plus_edynamix_demo_15
Browse files- src/minicpm/response.py +16 -16
src/minicpm/response.py
CHANGED
@@ -3,7 +3,7 @@ import sys
|
|
3 |
import gradio as gr
|
4 |
import spaces
|
5 |
from decord import VideoReader, cpu
|
6 |
-
from PIL import Image
|
7 |
# Local imports
|
8 |
from src.config import (
|
9 |
device,
|
@@ -21,22 +21,22 @@ from src.exception import CustomExceptionHandling
|
|
21 |
model, tokenizer, processor = load_model_tokenizer_and_processor(model_name, device)
|
22 |
MAX_NUM_FRAMES=64
|
23 |
|
24 |
-
def encode_video(video_path):
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
@spaces.GPU(duration=120)
|
42 |
def describe_image(
|
|
|
3 |
import gradio as gr
|
4 |
import spaces
|
5 |
from decord import VideoReader, cpu
|
6 |
+
# from PIL import Image
|
7 |
# Local imports
|
8 |
from src.config import (
|
9 |
device,
|
|
|
21 |
model, tokenizer, processor = load_model_tokenizer_and_processor(model_name, device)
|
22 |
MAX_NUM_FRAMES=64
|
23 |
|
24 |
+
# def encode_video(video_path):
|
25 |
+
# MAX_NUM_FRAMES=64
|
26 |
+
# def uniform_sample(l, n):
|
27 |
+
# gap = len(l) / n
|
28 |
+
# idxs = [int(i * gap + gap / 2) for i in range(n)]
|
29 |
+
# return [l[i] for i in idxs]
|
30 |
|
31 |
+
# vr = VideoReader(video_path, ctx=cpu(0))
|
32 |
+
# sample_fps = round(vr.get_avg_fps() / 1) # FPS
|
33 |
+
# frame_idx = [i for i in range(0, len(vr), sample_fps)]
|
34 |
+
# if len(frame_idx) > MAX_NUM_FRAMES:
|
35 |
+
# frame_idx = uniform_sample(frame_idx, MAX_NUM_FRAMES)
|
36 |
+
# frames = vr.get_batch(frame_idx).asnumpy()
|
37 |
+
# frames = [Image.fromarray(v.astype('uint8')) for v in frames]
|
38 |
+
# print('num frames:', len(frames))
|
39 |
+
# return frames
|
40 |
|
41 |
@spaces.GPU(duration=120)
|
42 |
def describe_image(
|