Spaces:
Runtime error
Runtime error
title: Image to Video Processing Pipelin | |
emoji: ๐ฅ | |
colorFrom: green | |
colorTo: red | |
sdk: gradio | |
sdk_version: 3.41.2 | |
app_file: app.py | |
pinned: false | |
license: apache-2.0 | |
# VideoProcessingPipeline(SNSๆ็จฟๅ็ป็ๆใใผใซ) | |
SNSใฎๆ็จฟใฏใ็ปๅใใใๅ็ปใฎๆนใๆณจ็ฎใ้ใใใใใใจใๅคใใงใใใใใใๅ็ปใไฝๆใใใฎใฏๆ้ใใใใใใฎใใใใงใๆๆใกใฎ็ปๅใใ่ชๅใง้ญ ๅ็ใชๅ็ปใ็ๆใใๆนๆณใใ็ดนไปใใพใใ | |
![](https://hamaruki.com/wp-content/uploads/2023/09/00028-1365031933-1-576x1024.png) | |
## ๆฆ่ฆ | |
### ในใใใ1: ๅฟ ่ฆใชใใผใซใฎๆบๅ | |
- Python็ฐๅข | |
- OpenCV | |
- PIL (Pillow) | |
ใใใใฏpipใไฝฟใฃใฆ็ฐกๅใซใคใณในใใผใซใงใใพใใ | |
```bash | |
pip install opencv-python pillow | |
``` | |
### ในใใใ2: ็ปๅใฎๆบๅ | |
ใพใใๅ็ปใซๅคๆใใใ็ปๅใไธใคใฎใใฉใซใใซใพใจใใพใใใใฎใใฉใซใใฎใในใๅพใงไฝฟ็จใใพใใ | |
### ในใใใ3: ็ปๅใฎใใฉใผๅฆ็ | |
ๅ็ปใไฝๆใใๅใซใ็ปๅใซใใฉใผๅนๆใ้ฉ็จใใพใใใใใซใใใๅ็ปใๆด็ทดใใใ้ฐๅฒๆฐใๆใคใใใซใชใใพใใ | |
ไปฅไธใฎใฏใฉในใ`BlurredBackgroundEmbedder`ใไฝฟ็จใใฆใ็ปๅใซใใฉใผๅนๆใ้ฉ็จใใพใใ | |
```python | |
processor = BlurredBackgroundEmbedder(r"path/to/your/image_folder") | |
processor.process_all_images() | |
``` | |
### ในใใใ4: ๅ็ปใฎไฝๆ | |
ใใฉใผๅฆ็ใใใ็ปๅใไฝฟ็จใใฆใๅ็ปใไฝๆใใพใใใใฎๅ็ปใฏใ็ปๅใไธใใไธใซในใฏใญใผใซใใใขใใกใผใทใงใณใๆใฃใฆใใพใใ | |
ไปฅไธใฎใฏใฉในใ`FrameVideoCreator`ใไฝฟ็จใใฆๅ็ปใไฝๆใใพใใ | |
```python | |
video_creator = FrameVideoCreator() | |
video_creator.process_folder(r"path/to/your/image_folder_Blurred") | |
``` | |
### ในใใใ5: ๅ็ปใฎ้ฃ็ต | |
่คๆฐใฎๅ็ปใไธใคใซ้ฃ็ตใใพใใใพใใๅ็ป้ใฎ้ท็งปใฏในใ ใผใบใชใขใซใใกใใฌใณใใ้ฉ็จใใใพใใ | |
```python | |
merger = VideoMergerWithSmoothTransition() | |
input_folder_path = r"path/to/your/image_folder_Blurred_mov" | |
output_folder_path = f"{input_folder_path}_Final" | |
os.makedirs(output_folder_path, exist_ok=True) | |
output_video_path = os.path.join(output_folder_path, "concatenated_video.mp4") | |
merger.merge_videos(input_folder_path, output_video_path) | |
``` | |
### ในใใใ6: ๅ็ปใฎ็ขบ่ช | |
ๅบๅใใฉใซใใซไฟๅญใใใๅ็ปใ็ขบ่ชใใพใใใใฎๅ็ปใSNSใซใขใใใญใผใใใใใจใงใ้ญ ๅ็ใชๆ็จฟใ็ฐกๅใซไฝๆใงใใพใใ | |
## ไฝฟ็จๆนๆณ | |
`VideoProcessingPipeline`ใฏใๆๅฎใใใ็ปๅใใฉใซใๅ ใฎ็ปๅใๅฆ็ใใๅ็ปใไฝๆใใๅ็ปใ้ฃ็ตใใไธ้ฃใฎใฟในใฏใๅฎ่กใใPythonใฏใฉในใงใใ | |
### ใฏใคใใฏในใฟใผใ | |
1. ใพใใๅฟ ่ฆใชใขใธใฅใผใซใใคใณใใผใใใพใใ | |
```python | |
from modules.utils import v_image_blurred_utils | |
from modules.BlurredBackgroundEmbedder import BlurredBackgroundEmbedder | |
from modules.FrameVideoCreator import FrameVideoCreator | |
from modules.Transition.VideoMergerWithSmoothTransition import VideoMergerWithSmoothTransition | |
``` | |
1. `VideoProcessingPipeline`ใฏใฉในใๅๆๅใใพใใใใฎใจใใ็ปๅใๆ ผ็ดใใใฆใใใใฉใซใใฎใในใๅผๆฐใจใใฆๆธกใใพใใ | |
```python | |
pipeline = VideoProcessingPipeline(r"path/to/your/image_folder") | |
``` | |
1. `execute_pipeline`ใกใฝใใใๅผใณๅบใใฆใ็ปๅใฎๅฆ็ใๅ็ปใฎไฝๆใๅ็ปใฎ้ฃ็ตใ้ ็ชใซๅฎ่กใใพใใ | |
```python | |
pipeline.execute_pipeline() | |
``` | |
### ๅ ้จใฎๅไฝ | |
- **็ปๅใฎใใฉใผๅฆ็** : ็ปๅใซใใฉใผๅนๆใ้ฉ็จใใๆฐใใใใฉใซใใซไฟๅญใใพใใ | |
- **ๅ็ปใฎไฝๆ** : ใใฉใผๅฆ็ใใใ็ปๅใใใไธใใไธใซ็งปๅใใใขใใกใผใทใงใณๅนๆใๆใคๅ็ปใไฝๆใใพใใ | |
- **ๅ็ปใฎ้ฃ็ต** : ใในใฆใฎๅ็ปใไธใคใฎๅ็ปใซ้ฃ็ตใใพใใๅ็ป้ใฎ้ท็งปใฏในใ ใผใบใชใขใซใใกใใฌใณใใ้ฉ็จใใใพใใ | |
### ๆณจๆ็น | |
- ๅ ฅๅใจใใฆๆธกใใใ็ปๅใใฉใซใใซใฏใ้ฃ็ตใใใ็ปๅใฎใฟใๅซใพใใฆใใใใจใ็ขบ่ชใใฆใใ ใใใ | |
- ็ๆใใใๅ็ปใฏใ`image_folder_Blurred_mov_Final`ใจใใๅๅใฎใใฉใซใใซไฟๅญใใใพใใ | |
## ่งฃ่ชฌใตใคใ | |
่ฉณ็ดฐใช่งฃ่ชฌใฏใใกใ | |
https://hamaruki.com/automatically-generate-posted-videos-from-images/ | |
## ใพใจใ | |
Pythonใไฝฟ็จใใฆใๆๆใกใฎ็ปๅใใSNSใซๆ็จฟใใใใใฎๅ็ปใ็ฐกๅใซ่ชๅ็ๆใใๆนๆณใๅญฆใณใพใใใใใฎๆนๆณใๆดป็จใใใฐใ่ฆ่ฆ็ใซ้ญ ๅ็ใชSNSใฎๆ็จฟใ็ฐกๅใซไฝๆใงใใพใใๅๅฟ่ ใฎๆนใงใใในใใใใ่ฟฝใฃใฆๅฎ่กใใใฐใๆ่ปฝใซๅ็ปใ็ๆใงใใใฎใงใใใฒ่ฉฆใใฆใฟใฆใใ ใใใ | |