ahmad walidurosyad commited on
Commit
0881e36
·
1 Parent(s): 9fd445b

Complete Video Subtitle Remover with Git LFS

Browse files
.gitattributes ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ *.pdiparams filter=lfs diff=lfs merge=lfs -text
2
+ *.pdmodel filter=lfs diff=lfs merge=lfs -text
3
+ *.pth filter=lfs diff=lfs merge=lfs -text
4
+ *.pt filter=lfs diff=lfs merge=lfs -text
5
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
backend/__pycache__/config.cpython-314.pyc ADDED
Binary file (5.43 kB). View file
 
backend/models/V4/ch_det/inference.pdmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64b2bd98be520804dae456a57a38707aa6051cb7cfd442b56cf85d92cc5a299b
3
+ size 2203033
backend/models/V4/ch_det/inference_1.pdiparams ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b287157513150c1bc3c8489d7d975b255bdd13172118863d6bf2e5082f686594
3
+ size 50000000
backend/models/V4/ch_det/inference_2.pdiparams ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36e1994b0d2a8f9a47e62fdf55c2ca3c9f6ff06acd1f79cc8da44abbb9e44404
3
+ size 50000000
backend/models/V4/ch_det/inference_3.pdiparams ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acd34281a1cc220cc8ef094a4b935718686fa7eaef23ab77e6baac80badacc32
3
+ size 13295054
backend/models/V4/ch_det_fast/inference.pdiparams ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49ee815e30cff43cb1057d33bf0d94193e4d4f1ae28451cad15b40be830df915
3
+ size 4692937
backend/models/V4/ch_det_fast/inference.pdmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ad68ed2768fe6c41166a5bc64680cc9f445390acb6528da449a4db2f7b90e14
3
+ size 166367
google_colabs/fix_notebook.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Update Colab notebook with new Stable Diffusion, DiffuEraser, and E2FGVI options
4
+ """
5
+ import json
6
+
7
+ # Read the notebook
8
+ with open('Video_Subtitle_Remover.ipynb', 'r') as f:
9
+ nb = json.load(f)
10
+
11
+ # 1. Update Step 3 - Add new dependencies
12
+ for i, cell in enumerate(nb['cells']):
13
+ if cell['cell_type'] == 'code' and cell['source']:
14
+ source = ''.join(cell['source'])
15
+ if 'pip install -q filesplit==3.0.2' in source:
16
+ # Add diffusers and related packages
17
+ cell['source'] = [
18
+ "# Install dependencies\n",
19
+ "# Note: Colab already has torch, torchvision, opencv-python, numpy, etc.\n",
20
+ "!pip install -q filesplit==3.0.2 albumentations scikit-image imgaug pyclipper lmdb\n",
21
+ "!pip install -q PyYAML omegaconf tqdm easydict scikit-learn pandas webdataset\n",
22
+ "!pip install -q protobuf av einops paddleocr paddle2onnx onnxruntime-gpu\n",
23
+ "\n",
24
+ "# Install PaddlePaddle GPU version (compatible with Colab)\n",
25
+ "!pip install -q paddlepaddle-gpu==2.6.2\n",
26
+ "\n",
27
+ "# Advanced Inpainting Models (Optional - only install if using these modes)\n",
28
+ "# Uncomment the line below to enable Stable Diffusion, DiffuEraser, E2FGVI\n",
29
+ "# !pip install -q diffusers transformers accelerate\n",
30
+ "\n",
31
+ "print(\"✓ Dependencies installed!\")"
32
+ ]
33
+ print(f"✓ Updated Step 3 (Cell {i}): Added advanced model dependencies")
34
+ break
35
+
36
+ # 2. Update Step 5 - Add new algorithm options
37
+ for i, cell in enumerate(nb['cells']):
38
+ if cell['cell_type'] == 'code' and cell['source']:
39
+ source = ''.join(cell['source'])
40
+ if 'ALGORITHM =' in source and '# === CONFIGURATION ===' in source:
41
+ cell['source'] = [
42
+ "# === CONFIGURATION ===\n",
43
+ "\n",
44
+ "# Algorithm selection\n",
45
+ "# Options:\n",
46
+ "# 'STTN' - Fast, real-time video (recommended for Colab)\n",
47
+ "# 'LAMA' - High quality for images/animation\n",
48
+ "# 'PROPAINTER' - Best quality, very slow, high VRAM\n",
49
+ "# 'SD' - Stable Diffusion (NEW - requires extra install above)\n",
50
+ "# 'DIFFUERASER' - Specialized subtitle removal (Coming soon)\n",
51
+ "# 'E2FGVI' - Fast flow-guided (Coming soon)\n",
52
+ "ALGORITHM = 'STTN'\n",
53
+ "\n",
54
+ "# STTN Settings (recommended for Colab)\n",
55
+ "STTN_SKIP_DETECTION = True # Much faster, processes entire subtitle area\n",
56
+ "STTN_MAX_LOAD_NUM = 40 # Reduce if OOM (30-50 for T4 GPU)\n",
57
+ "STTN_NEIGHBOR_STRIDE = 5\n",
58
+ "STTN_REFERENCE_LENGTH = 10\n",
59
+ "\n",
60
+ "# LAMA Settings\n",
61
+ "LAMA_SUPER_FAST = False # Set True for faster but lower quality\n",
62
+ "\n",
63
+ "# ProPainter Settings (requires 16GB+ GPU, not recommended for Colab)\n",
64
+ "PROPAINTER_MAX_LOAD_NUM = 40 # Very low for T4 GPU\n",
65
+ "\n",
66
+ "# Stable Diffusion Settings (NEW)\n",
67
+ "SD_STEPS = 50 # More steps = better quality but slower\n",
68
+ "SD_GUIDANCE_SCALE = 7.5 # How much to follow the prompt\n",
69
+ "SD_PROMPT = \"natural scene, high quality\" # Text guidance\n",
70
+ "\n",
71
+ "# Video path (change this)\n",
72
+ "# Option 1: Use sample video\n",
73
+ "VIDEO_PATH = '/content/video-subtitle-remover/test/test.mp4'\n",
74
+ "\n",
75
+ "# Option 2: Use video from Google Drive (uncomment)\n",
76
+ "# VIDEO_PATH = '/content/drive/MyDrive/my_video.mp4'\n",
77
+ "\n",
78
+ "# Subtitle area (optional, in pixels: ymin, ymax, xmin, xmax)\n",
79
+ "# None = auto-detect subtitle area\n",
80
+ "SUBTITLE_AREA = None\n",
81
+ "\n",
82
+ "# Example: Bottom 20% of 1080p video\n",
83
+ "# SUBTITLE_AREA = (864, 1080, 0, 1920)\n",
84
+ "\n",
85
+ "print(f\"Configuration:\")\n",
86
+ "print(f\" Algorithm: {ALGORITHM}\")\n",
87
+ "print(f\" Video: {VIDEO_PATH}\")\n",
88
+ "print(f\" Subtitle area: {SUBTITLE_AREA or 'Auto-detect'}\")"
89
+ ]
90
+ print(f"✓ Updated Step 5 (Cell {i}): Added SD/DiffuEraser/E2FGVI options")
91
+ break
92
+
93
+ # 3. Update Step 6 - Handle new algorithms
94
+ for i, cell in enumerate(nb['cells']):
95
+ if cell['cell_type'] == 'code' and cell['source']:
96
+ source = ''.join(cell['source'])
97
+ if 'config.MODE = InpaintMode.STTN' in source:
98
+ cell['source'] = [
99
+ "# Modify config.py with our settings\n",
100
+ "import sys\n",
101
+ "sys.path.insert(0, '/content/video-subtitle-remover')\n",
102
+ "sys.path.insert(0, '/content/video-subtitle-remover/backend')\n",
103
+ "\n",
104
+ "from backend import config\n",
105
+ "from backend.config import InpaintMode\n",
106
+ "\n",
107
+ "# Apply algorithm selection\n",
108
+ "if ALGORITHM == 'STTN':\n",
109
+ " config.MODE = InpaintMode.STTN\n",
110
+ " config.STTN_SKIP_DETECTION = STTN_SKIP_DETECTION\n",
111
+ " config.STTN_MAX_LOAD_NUM = STTN_MAX_LOAD_NUM\n",
112
+ " config.STTN_NEIGHBOR_STRIDE = STTN_NEIGHBOR_STRIDE\n",
113
+ " config.STTN_REFERENCE_LENGTH = STTN_REFERENCE_LENGTH\n",
114
+ "elif ALGORITHM == 'LAMA':\n",
115
+ " config.MODE = InpaintMode.LAMA\n",
116
+ " config.LAMA_SUPER_FAST = LAMA_SUPER_FAST\n",
117
+ "elif ALGORITHM == 'PROPAINTER':\n",
118
+ " config.MODE = InpaintMode.PROPAINTER\n",
119
+ " config.PROPAINTER_MAX_LOAD_NUM = PROPAINTER_MAX_LOAD_NUM\n",
120
+ "elif ALGORITHM == 'SD':\n",
121
+ " config.MODE = InpaintMode.STABLE_DIFFUSION\n",
122
+ " config.SD_STEPS = SD_STEPS\n",
123
+ " config.SD_GUIDANCE_SCALE = SD_GUIDANCE_SCALE\n",
124
+ " config.SD_PROMPT = SD_PROMPT\n",
125
+ "elif ALGORITHM == 'DIFFUERASER':\n",
126
+ " config.MODE = InpaintMode.DIFFUERASER\n",
127
+ " print('⚠️ DiffuEraser not yet implemented, will fall back to LAMA')\n",
128
+ "elif ALGORITHM == 'E2FGVI':\n",
129
+ " config.MODE = InpaintMode.E2FGVI\n",
130
+ " print('⚠️ E2FGVI not yet implemented, will fall back to STTN')\n",
131
+ "\n",
132
+ "print(f\"✓ Configuration applied!\")\n",
133
+ "print(f\" Using device: {config.device}\")\n",
134
+ "print(f\" Mode: {config.MODE.value}\")"
135
+ ]
136
+ print(f"✓ Updated Step 6 (Cell {i}): Added new algorithm handling")
137
+ break
138
+
139
+ # Save the notebook
140
+ with open('Video_Subtitle_Remover.ipynb', 'w') as f:
141
+ json.dump(nb, f, indent=1, ensure_ascii=False)
142
+
143
+ print("\n✓ Colab notebook updated!")
144
+ print("\nChanges made:")
145
+ print(" 1. Step 3: Added diffusers/transformers (commented out by default)")
146
+ print(" 2. Step 5: Added SD, DiffuEraser, E2FGVI options")
147
+ print(" 3. Step 5: Added SD configuration parameters")
148
+ print(" 4. Step 6: Added handling for new algorithms")
test/test.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7c6bb6f2bd0fff4af75f7b3ec969ec976f8ca9c2c86687c6117598069139a66
3
+ size 5335235
test/test.png ADDED
test/test1.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73b347ac0d0dd4a6e8e2b999727aaf44620227614742054681d3e20c28dc75a2
3
+ size 5596517
test/test2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c1f33de3957436dde22dcecf4e19c1ecf8252f5c544ecdb6f565b44e26d0ff6
3
+ size 914010
test/test3.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1458093ddc57da7d8d52ec584ad22935eadb5d474a1ec9a7d0cfda8f835390a
3
+ size 4438677
test/test4.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a5b2ed88800f8a878f01d10d38b805edcf9e28a50e537dc84f561e1460c7567
3
+ size 19471300