explaingit

mlfarinha/pixlrelight

13PythonAudience · researcherComplexity · 3/5LicenseSetup · moderate

TLDR

A Python research tool from Oxford that changes the lighting in a photograph to match a target you provide, using either a reference photo or Blender render outputs, and produces the result in under 100 milliseconds.

Mindmap

mindmap
  root((PIXLRelight))
    What It Does
      Photo relighting
      Single image input
      Fast inference
    Input Modes
      Reference photo
      Blender render passes
    Tech Stack
      Python
      PyTorch
      Conda
    Use Cases
      Product photography
      Portrait editing
      Batch relighting
    Audience
      Researchers
      Visual artists
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Change the lighting of a product or portrait photograph to match a reference image without reshooting in a different environment.

USE CASE 2

Apply a precisely controlled light setup from a Blender Cycles scene to a real photograph for physically accurate relighting.

USE CASE 3

Batch-process a folder of images to apply consistent new lighting conditions using a single command-line call.

Tech stack

PythonPyTorchCondaBlender

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Python 3.11 and a conda environment, model weights download automatically from Hugging Face on first run but carry a non-commercial license.

The code is MIT licensed and free to modify, but the model weights carry a non-commercial Creative Commons license, so commercial use of this tool is not permitted.

In plain English

PIXLRelight is a Python tool from researchers at the University of Oxford that takes a single photograph and changes its lighting to match a target illumination you provide. You give it a source photo and either another photo showing the lighting you want, or a set of 3D render outputs from a program called Blender, and it produces a new version of your source photo lit as if it were in that new environment. The whole process takes less than a tenth of a second. The tool has two main ways to specify the new lighting. In the first mode, you provide a real reference photograph, and the system automatically extracts information about the light conditions from it using a separate built-in model. In the second mode, you supply output files from Blender Cycles, a 3D rendering engine, which lets you define exactly where lights are placed and how they behave. This second mode is for users who want precise, physically accurate control over the final result. Installation requires Python 3.11 and a conda environment. The model weights download automatically from Hugging Face on first use. Running inference is a single command pointing at an input folder. The tool handles both single images and batches, and automatically determines which mode to use based on what files are present in each sample folder. The underlying approach connects physically based rendering with a neural image model. A transformer-based neural renderer reads intrinsic image properties, things like diffuse shading and specular reflections extracted from either the reference photo or the Blender render passes, and uses them to relight the source image while preserving fine detail at the original resolution. The code is released under the MIT license, and the model weights carry a non-commercial Creative Commons license, so commercial use of the weights is not permitted.

Copy-paste prompts

Prompt 1
I want to relight a portrait photo using PIXLRelight with a reference photo as the target lighting. Show me the required folder structure and the command to run inference.
Prompt 2
How do I set up a Blender Cycles scene to export the render pass files that PIXLRelight needs for its precise lighting control mode?
Prompt 3
PIXLRelight is downloading model weights from Hugging Face on first run but failing. What is the expected download folder structure and how can I pre-download the weights manually?
Prompt 4
I have 50 product images I want to relight with the same reference photo. How does PIXLRelight handle batch inputs and how should I organize the sample folders?
Open on GitHub → Explain another repo

← mlfarinha on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.