varshith15/Qwen-Image-2509-MultipleAngles

11

stars

1

commits

Python

primary language

Nov 7, 2025

updated

README

Qwen-Image-2509-MultipleAngles

Apply camera transformations to images and videos using Qwen-Image-Edit-2509 with Multiple Angles LoRA.

🎥 Features

  • 🎨 Image Processing: Interactive Gradio UI for single image transformations
  • 🎬 Video Processing: Command-line tools for processing entire videos frame by frame
  • 📦 Batch Processing: Process multiple videos at once with different settings
  • 🎯 Multiple Camera Operations: Rotation, zoom, close-up, angle changes, and more
  • ⚡ Optimized Processing: Frame skipping and parallel processing support

📦 Installation

Requirements

  • Python 3.8+
  • CUDA-capable GPU (16GB+ VRAM recommended)
  • PyTorch with CUDA support

Install Dependencies

pip install -r requirements.txt

Test Installation

python test_installation.py

Note: The optimization module is only available on HuggingFace Spaces and is not required for local processing. You may see a note about it being unavailable - this is expected and does not affect functionality.

🚀 Quick Start

Image Processing (Gradio UI)

Launch the interactive web interface:

python app.py

Then open your browser and upload an image to apply camera transformations.

Video Processing

Process a Single Video

python process_video.py input.mp4 --operation rotate_left_45

This creates input_processed.mp4 with the camera rotated 45° to the left.

Quick Test (First 10 Frames)

python process_video.py video.mp4 --operation close_up --max-frames 10

Fast Processing (Skip Frames)

# Process every 2nd frame (2x faster)
python process_video.py video.mp4 --operation rotate_left_45 --skip-frames 2

# Process every 4th frame (4x faster)
python process_video.py video.mp4 --operation zoom_out --skip-frames 4

Batch Process Multiple Videos

# Process all videos in a directory
python batch_process_videos.py --dir ./videos --operation close_up

# Or create a config file
python batch_process_videos.py --create-config
# Edit batch_config.json, then run:
python batch_process_videos.py --config batch_config.json

🎯 Available Camera Operations

OperationDescription
rotate_left_45Rotate camera 45° to the left
rotate_right_45Rotate camera 45° to the right
rotate_left_90Rotate camera 90° to the left
rotate_right_90Rotate camera 90° to the right
top_downSwitch to bird's eye / top-down view
low_angleSwitch to low-angle / looking up view
close_upClose-up lens (zoom in close)
medium_close_upMedium close-up lens
zoom_outZoom out / pull camera back

📖 Advanced Usage

Custom Prompts

You can use custom prompts in Chinese for more control:

python process_video.py input.mp4 --custom-prompt "将镜头转为斜俯视 并 拉远镜头"

Additional Prompt Context

Add extra context to any operation:

python process_video.py input.mp4 --operation close_up --extra-prompt "被摄体是一名女孩子"

Quality & Speed Control

# Faster processing (fewer inference steps)
python process_video.py input.mp4 --steps 2

# Higher quality (more inference steps)
python process_video.py input.mp4 --steps 8

# Adjust guidance scale for output control
python process_video.py input.mp4 --guidance-scale 2.0

Output Control

# Specify output path
python process_video.py input.mp4 --output my_output.mp4

# Keep intermediate frames for inspection
python process_video.py input.mp4 --keep-frames

# Change working directory for temporary files
python process_video.py input.mp4 --work-dir /tmp/video_work

# Set random seed for reproducibility
python process_video.py input.mp4 --seed 42

Complete Example

python process_video.py \
  my_video.mp4 \
  --output rotated_video.mp4 \
  --operation rotate_right_90 \
  --extra-prompt "outdoor scene" \
  --steps 4 \
  --guidance-scale 1.0 \
  --skip-frames 2 \
  --seed 123 \
  --keep-frames

📊 Performance Tips

  1. Always Test First: Use --max-frames 10 to test settings before processing full videos
  2. Frame Skipping: Use --skip-frames 2 for 2x speed with minimal quality loss
  3. GPU Memory: If you encounter OOM errors, skip more frames or process shorter segments
  4. Inference Steps: Default 4 steps work well; 8 steps for higher quality; 2 steps for faster processing
  5. Batch Processing: For very long videos, consider splitting into segments first

Expected Processing Times

On RTX 4080 (16GB VRAM):

  • 10 frames: ~1-2 minutes
  • 100 frames: ~10-15 minutes
  • 1000 frames (30s video @ 30fps): ~1.5-2 hours
  • With --skip-frames 2: 50% faster
  • With --skip-frames 4: 75% faster

🛠️ Command-Line Options

process_video.py

python process_video.py --help

Key options:

  • --output: Output video path
  • --operation: Camera operation to apply
  • --custom-prompt: Custom Chinese prompt (overrides operation)
  • --extra-prompt: Additional prompt text
  • --seed: Random seed for reproducibility
  • --steps: Number of inference steps (default: 4)
  • --guidance-scale: True guidance scale (default: 1.0)
  • --max-frames: Maximum frames to process (for testing)
  • --skip-frames: Process every Nth frame (1=all, 2=every other, etc.)
  • --keep-frames: Keep extracted and processed frames
  • --work-dir: Working directory for temporary frames

batch_process_videos.py

python batch_process_videos.py --help

Key options:

  • --dir: Directory containing videos
  • --operation: Camera operation for all videos
  • --config: JSON config file for batch processing
  • --create-config: Generate example config file

🔧 Troubleshooting

Out of Memory Error

If you encounter CUDA out of memory errors:

  1. Try processing fewer frames: --skip-frames 2 or higher
  2. Close other GPU applications
  3. Process shorter video segments
  4. Use --max-frames to limit frame count

Slow Processing

  • Reduce inference steps: --steps 2
  • Skip frames: --skip-frames 2 or higher
  • Test with fewer frames first: --max-frames 50

Poor Quality Output

  • Increase inference steps: --steps 8
  • Adjust guidance scale: --guidance-scale 1.5
  • Try different prompts or operations
  • Process all frames: --skip-frames 1

Import Errors

Make sure all dependencies are installed:

pip install -r requirements.txt

📝 How It Works

  1. Frame Extraction: Extracts frames from input video using OpenCV
  2. Processing: Each frame is processed through Qwen-Image-Edit-2509 pipeline with specified camera transformation
  3. Video Reconstruction: Processed frames are reassembled into video at original FPS
  4. Cleanup: Temporary frames are deleted unless --keep-frames is specified

Note: Audio is not preserved as this is an image processing pipeline.

🔄 Recent Updates

This fork adds comprehensive video processing capabilities:

  • Video Processing: Frame-by-frame video processing with process_video.py
  • Batch Processing: Multi-video batch processing with batch_process_videos.py
  • Frame Skipping: Configurable frame skipping for faster processing
  • Frame Limits: Test mode with --max-frames for quick validation
  • Seed Control: Reproducible results with per-frame seed variation
  • Working Directory: Customizable temp directory for frame storage
  • Keep Frames: Option to preserve intermediate frames for debugging
  • Example Scripts: Shell script examples for common operations
  • Comprehensive Documentation: Installation guide, quick start, and troubleshooting

🙏 Credits

Original Space & Base Implementation:

Models & LoRA Weights:

Video Processing Enhancement:

  • This fork adds video processing capabilities built on top of the original image processing implementation

📄 License

Apache 2.0


Made with ❤️ building on the excellent work by the Qwen Team

Contributors

varshith15

1 commits

varshith15/Qwen-Image-2509-MultipleAngles

11

stars

1

commits

Python

primary language

Nov 7, 2025

updated

README

Qwen-Image-2509-MultipleAngles

Apply camera transformations to images and videos using Qwen-Image-Edit-2509 with Multiple Angles LoRA.

🎥 Features

  • 🎨 Image Processing: Interactive Gradio UI for single image transformations
  • 🎬 Video Processing: Command-line tools for processing entire videos frame by frame
  • 📦 Batch Processing: Process multiple videos at once with different settings
  • 🎯 Multiple Camera Operations: Rotation, zoom, close-up, angle changes, and more
  • ⚡ Optimized Processing: Frame skipping and parallel processing support

📦 Installation

Requirements

  • Python 3.8+
  • CUDA-capable GPU (16GB+ VRAM recommended)
  • PyTorch with CUDA support

Install Dependencies

pip install -r requirements.txt

Test Installation

python test_installation.py

Note: The optimization module is only available on HuggingFace Spaces and is not required for local processing. You may see a note about it being unavailable - this is expected and does not affect functionality.

🚀 Quick Start

Image Processing (Gradio UI)

Launch the interactive web interface:

python app.py

Then open your browser and upload an image to apply camera transformations.

Video Processing

Process a Single Video

python process_video.py input.mp4 --operation rotate_left_45

This creates input_processed.mp4 with the camera rotated 45° to the left.

Quick Test (First 10 Frames)

python process_video.py video.mp4 --operation close_up --max-frames 10

Fast Processing (Skip Frames)

# Process every 2nd frame (2x faster)
python process_video.py video.mp4 --operation rotate_left_45 --skip-frames 2

# Process every 4th frame (4x faster)
python process_video.py video.mp4 --operation zoom_out --skip-frames 4

Batch Process Multiple Videos

# Process all videos in a directory
python batch_process_videos.py --dir ./videos --operation close_up

# Or create a config file
python batch_process_videos.py --create-config
# Edit batch_config.json, then run:
python batch_process_videos.py --config batch_config.json

🎯 Available Camera Operations

OperationDescription
rotate_left_45Rotate camera 45° to the left
rotate_right_45Rotate camera 45° to the right
rotate_left_90Rotate camera 90° to the left
rotate_right_90Rotate camera 90° to the right
top_downSwitch to bird's eye / top-down view
low_angleSwitch to low-angle / looking up view
close_upClose-up lens (zoom in close)
medium_close_upMedium close-up lens
zoom_outZoom out / pull camera back

📖 Advanced Usage

Custom Prompts

You can use custom prompts in Chinese for more control:

python process_video.py input.mp4 --custom-prompt "将镜头转为斜俯视 并 拉远镜头"

Additional Prompt Context

Add extra context to any operation:

python process_video.py input.mp4 --operation close_up --extra-prompt "被摄体是一名女孩子"

Quality & Speed Control

# Faster processing (fewer inference steps)
python process_video.py input.mp4 --steps 2

# Higher quality (more inference steps)
python process_video.py input.mp4 --steps 8

# Adjust guidance scale for output control
python process_video.py input.mp4 --guidance-scale 2.0

Output Control

# Specify output path
python process_video.py input.mp4 --output my_output.mp4

# Keep intermediate frames for inspection
python process_video.py input.mp4 --keep-frames

# Change working directory for temporary files
python process_video.py input.mp4 --work-dir /tmp/video_work

# Set random seed for reproducibility
python process_video.py input.mp4 --seed 42

Complete Example

python process_video.py \
  my_video.mp4 \
  --output rotated_video.mp4 \
  --operation rotate_right_90 \
  --extra-prompt "outdoor scene" \
  --steps 4 \
  --guidance-scale 1.0 \
  --skip-frames 2 \
  --seed 123 \
  --keep-frames

📊 Performance Tips

  1. Always Test First: Use --max-frames 10 to test settings before processing full videos
  2. Frame Skipping: Use --skip-frames 2 for 2x speed with minimal quality loss
  3. GPU Memory: If you encounter OOM errors, skip more frames or process shorter segments
  4. Inference Steps: Default 4 steps work well; 8 steps for higher quality; 2 steps for faster processing
  5. Batch Processing: For very long videos, consider splitting into segments first

Expected Processing Times

On RTX 4080 (16GB VRAM):

  • 10 frames: ~1-2 minutes
  • 100 frames: ~10-15 minutes
  • 1000 frames (30s video @ 30fps): ~1.5-2 hours
  • With --skip-frames 2: 50% faster
  • With --skip-frames 4: 75% faster

🛠️ Command-Line Options

process_video.py

python process_video.py --help

Key options:

  • --output: Output video path
  • --operation: Camera operation to apply
  • --custom-prompt: Custom Chinese prompt (overrides operation)
  • --extra-prompt: Additional prompt text
  • --seed: Random seed for reproducibility
  • --steps: Number of inference steps (default: 4)
  • --guidance-scale: True guidance scale (default: 1.0)
  • --max-frames: Maximum frames to process (for testing)
  • --skip-frames: Process every Nth frame (1=all, 2=every other, etc.)
  • --keep-frames: Keep extracted and processed frames
  • --work-dir: Working directory for temporary frames

batch_process_videos.py

python batch_process_videos.py --help

Key options:

  • --dir: Directory containing videos
  • --operation: Camera operation for all videos
  • --config: JSON config file for batch processing
  • --create-config: Generate example config file

🔧 Troubleshooting

Out of Memory Error

If you encounter CUDA out of memory errors:

  1. Try processing fewer frames: --skip-frames 2 or higher
  2. Close other GPU applications
  3. Process shorter video segments
  4. Use --max-frames to limit frame count

Slow Processing

  • Reduce inference steps: --steps 2
  • Skip frames: --skip-frames 2 or higher
  • Test with fewer frames first: --max-frames 50

Poor Quality Output

  • Increase inference steps: --steps 8
  • Adjust guidance scale: --guidance-scale 1.5
  • Try different prompts or operations
  • Process all frames: --skip-frames 1

Import Errors

Make sure all dependencies are installed:

pip install -r requirements.txt

📝 How It Works

  1. Frame Extraction: Extracts frames from input video using OpenCV
  2. Processing: Each frame is processed through Qwen-Image-Edit-2509 pipeline with specified camera transformation
  3. Video Reconstruction: Processed frames are reassembled into video at original FPS
  4. Cleanup: Temporary frames are deleted unless --keep-frames is specified

Note: Audio is not preserved as this is an image processing pipeline.

🔄 Recent Updates

This fork adds comprehensive video processing capabilities:

  • Video Processing: Frame-by-frame video processing with process_video.py
  • Batch Processing: Multi-video batch processing with batch_process_videos.py
  • Frame Skipping: Configurable frame skipping for faster processing
  • Frame Limits: Test mode with --max-frames for quick validation
  • Seed Control: Reproducible results with per-frame seed variation
  • Working Directory: Customizable temp directory for frame storage
  • Keep Frames: Option to preserve intermediate frames for debugging
  • Example Scripts: Shell script examples for common operations
  • Comprehensive Documentation: Installation guide, quick start, and troubleshooting

🙏 Credits

Original Space & Base Implementation:

Models & LoRA Weights:

Video Processing Enhancement:

  • This fork adds video processing capabilities built on top of the original image processing implementation

📄 License

Apache 2.0


Made with ❤️ building on the excellent work by the Qwen Team

Contributors

varshith15

1 commits

Languages

Python

98.5%

Shell

1.5%