Skip to content

Commit

Permalink
Merge pull request #50 from myhloli/main
Browse files Browse the repository at this point in the history
refactor(datasets): remove unused video processing code and update dependencies
  • Loading branch information
wangbinDL authored Dec 26, 2024
2 parents fb3dc96 + 0bd9565 commit a5f4574
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "unimernet"
version = "0.2.2"
version = "0.2.3"
description = 'UniMERNet: A Universal Network for Real-World Mathematical Expression Recognition'
authors = ["Bin Wang <[email protected]>"]
readme = "README.md"
Expand Down Expand Up @@ -30,7 +30,6 @@ fairscale = "^0.4.13"
ftfy = {version = "^6.2.0", python = ">=3.10,<4.0"}
albumentations = "^1.4.4"
wand = "^0.6.13"
eva-decord = "^0.6.1"
webdataset = "^0.2.86"
rapidfuzz = "^3.8.1"
termcolor = "^2.4.0"
Expand Down
26 changes: 0 additions & 26 deletions unimernet/datasets/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,17 @@
import tarfile
import zipfile

import decord
import webdataset as wds
import numpy as np
import torch
from torch.utils.data.dataset import IterableDataset, ChainDataset
from decord import VideoReader
from unimernet.common.registry import registry
from unimernet.datasets.datasets.base_dataset import ConcatDataset
from tqdm import tqdm

decord.bridge.set_bridge("torch")
MAX_INT = registry.get("MAX_INT")


def load_video(video_path, n_frms=MAX_INT, height=-1, width=-1, sampling="uniform"):
vr = VideoReader(uri=video_path, height=height, width=width)

vlen = len(vr)
start, end = 0, vlen

n_frms = min(n_frms, vlen)

if sampling == "uniform":
indices = np.arange(start, end, vlen / n_frms).astype(int)
elif sampling == "headtail":
indices_h = sorted(rnd.sample(range(vlen // 2), n_frms // 2))
indices_t = sorted(rnd.sample(range(vlen // 2, vlen), n_frms // 2))
indices = indices_h + indices_t
else:
raise NotImplementedError

# get_batch -> T, H, W, C
frms = vr.get_batch(indices).permute(3, 0, 1, 2).float() # (C, T, H, W)

return frms


def apply_to_sample(f, sample):
if len(sample) == 0:
return {}
Expand Down

0 comments on commit a5f4574

Please sign in to comment.