Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ __pycache__/
/checkpoints
/asset
data/tos.py
evaluation/livesports3kcc/livecc/*/*.json
evaluation/livesports3kcc/livecc/*/*.json
.gradio/certificate.pem
# Custom ignored
.DS_Store
/decord
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,81 @@ pip install livecc-utils==0.0.2

We finished all things in ```torch==2.6.0```, ```transformers==4.50.0```, ```liger-kernel==4.50.0```. But other versions should also work. Our full environment is [requirements.txt](requirements.txt).

---
#### Installation on Apple Silicon
Tested on M1 Max and M2 Max with 32Gb RAM. Not really real time but working ([Live demo](demo/sources/LiveCC_on_Apple_Silicon.mp4)).
**/!\ _Do not use requirements.txt_**
##### Requirements
Install developper tools
```sh
xcode-select --install
```
Install [oh-my-zsh](https://ohmyz.sh) (optionnal)
```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```
Install [miniconda](https://www.anaconda.com/docs/getting-started/miniconda/install#mac-os-terminal-installer)
```sh
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash ~/Miniconda3-latest-MacOSX-arm64.sh
```

Install [brew](https://brew.sh)
```sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
```
Install git-lfs
```sh
pip3 install git-lfs
git lfs install
```
##### Install LiveCC for Apple Silicon
Clone this other repo and switch to apple_silicon branch
```sh
git clone https://github.com/LeJeko/livecc.git
cd livecc
git checkout -f apple_silicon
```
Create conda environment
```sh
conda create -n livecc python=3.12
conda activate livecc
```
Install this specific version of ffmpeg
```sh
brew install ffmpeg@4
echo 'export PATH="/opt/homebrew/opt/ffmpeg@4/bin:$PATH"' >> ~/.zshrc
brew link ffmpeg@4
```
Compile decord for arm64
```sh
pip install cmake

git clone --recursive https://github.com/dmlc/decord
cd decord
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
cd ../python
pip install . --user
cd ../..
```
Install dependencies
```sh
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install transformers accelerate peft opencv-python datasets tensorboard gradio pillow-heif gpustat timm sentencepiece openai av qwen_vl_utils
pip install livecc-utils
```
##### Launch LiveCC
```sh
python -m demo.app
```

---
#### Advanced

If you want to delve into our data production pipeline:
Expand Down
Binary file added demo/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions demo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __call__(self, message: str = None, history: list[str] = None, state: dict =
gr_examples = gr.Examples(
examples=[
'demo/sources/howto_fix_laptop_mute_1080p.mp4',
'demo/sources/LiveCC_on_Apple_Silicon.mp4',
'demo/sources/writing_mute_1080p.mp4',
'demo/sources/spacex_falcon9_mute_1080p.mp4',
'demo/sources/warriors_vs_rockets_2025wcr1_mute_1080p.mp4',
Expand Down
17 changes: 11 additions & 6 deletions demo/infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import functools, torch
from liger_kernel.transformers import apply_liger_kernel_to_qwen2_vl
apply_liger_kernel_to_qwen2_vl()
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor, LogitsProcessor, logging
from livecc_utils import prepare_multiturn_multimodal_inputs_for_generation, get_smart_resized_clip, get_smart_resized_video_reader, _read_video_decord_plus, _spatial_resize_video
from qwen_vl_utils import process_vision_info
Expand Down Expand Up @@ -32,11 +30,18 @@ class LiveCCDemoInfer:
streaming_time_interval = streaming_fps_frames / fps
frame_time_interval = 1 / fps

def __init__(self, model_path: str = None, device: str = 'cuda'):
def __init__(self, model_path: str = None):
if torch.backends.mps.is_available():
device = 'mps'
elif torch.cuda.is_available():
device = 'cuda'
else:
device = 'cpu'
print(f"Using device: {device}")
self.model = Qwen2VLForConditionalGeneration.from_pretrained(
model_path, torch_dtype="auto",
device_map=device,
attn_implementation='flash_attention_2'
model_path, torch_dtype="auto",
device_map=device,
attn_implementation='flash_attention_2' if device == 'cuda' else None
)
self.processor = AutoProcessor.from_pretrained(model_path, use_fast=False)
self.streaming_eos_token_id = self.processor.tokenizer(' ...').input_ids[-1]
Expand Down
Binary file added demo/sources/.DS_Store
Binary file not shown.
Binary file added demo/sources/LiveCC_on_Apple_Silicon.mp4
Binary file not shown.
Binary file modified demo/sources/howto_fix_laptop_mute_1080p.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,4 @@ xxhash==3.5.0
yarl==1.18.3
yt-dlp==2025.2.19
zipp==3.21.0
zstandard==0.19.0
zstandard==0.19.0