PyHook is an MIT licensed software, written in Python and C++, for access and modification of ReShade back buffer.
PyHook consists of two elements:
- Python code that finds process with ReShade loaded, injects addon into itand allows to process frames in code via dynamic pipelines.
- C++ addon DLL written using ReShade API that exposes back buffer via shared memoryand allows to configure dynamic pipelines in ReShade Addon UI.
Table of Contents
- Graphical user interface that allows to manage multiple PyHook sessions
- Automatic ReShade detection and DLL validation
- Automatic addon DLL injection
- Shared memory as storage
- Dynamic pipelines ordering and settings in ReShade UI via addon
- Pipeline lifecycle support (load/process/unload)
- Pipeline settings callbacks (before and after change)
- Pipeline multi-pass - process frame multiple times in single pipeline
- Frame processing in Python via
numpyarray - JSON file with pipelines settings
- Local Python environment usage in pipeline code
- Automatic update
- Automatic pipeline files download
- Automatic requirements installation
- Session timings for each pipeline processing
| PyHook version | OpenGL | DirectX 9 | DirectX 10 | DirectX 11 | DirectX 12 | Vulkan |
|---|---|---|---|---|---|---|
| 32-bit | ✔ | ✔ | ✔ | ✔ | ✔* | ✔* |
| 64-bit | ✔ | ✔ | ✔ | ✔ | ✔* | ✔* |
ReShade <= 5.4.2 and PyHook <= 0.8.1 whole ImGui is affected by pipelines for these API, due to bug:ReShade <= 5.4.2 and PyHook > 0.8.1 ImGui is not affected but OSD window has cut-out background:Do note that multisampling is not supported by PyHook at all with any API.
Benchmark setup:
- UNIGINE Superposition 64-bit DX11
- 1280x720, windowed, lowest preset
- Intel Core i9 9900KS
- RTX 2080 Super 8GB
- 32GB DDR4 RAM
- Pipelines were run with
CUDAwith few additional runs labelled asCPU
Benchmark command:
$ .\superposition.exe -preset 0 -video_app direct3d11 -shaders_quality 0 -textures_quality 0 ^
-dof 0 -motion_blur 0 -video_vsync 0 -video_mode -1 ^
-console_command "world_load superposition/superposition && render_manager_create_textures 1" ^
-project_name Superposition -video_fullscreen 0 -video_width 1280 -video_height 720 ^
-extern_plugin GPUMonitor -mode 0 -sound 0 -tooltips 1Results:
| PyHook settings | FPS min | FPS avg | FPS max | Score |
|---|---|---|---|---|
| PyHook disabled | 128 | 227 | 331 | 30357 |
| PyHook enabled | 76 | 101 | 120 | 13449 |
30
CUDA15
CPU |
33
CUDA15
CPU |
35
CUDA16
CPU |
4472
CUDA2052
CPU |
|
| 9 | 10 | 10 | 1305 | |
| 6 | 6 | 6 | 783 | |
YOLO Model: Medium
|
28
CUDA4
CPU |
32
CUDA4
CPU |
36
CUDA4
CPU |
4275
CUDA537
CPU |
| 8 | 8 | 8 | 1100 | |
| 9 | 9 | 9 | 1207 | |
Amount: 1.0
|
51 CPU |
61 CPU |
67 CPU |
8128 CPU |
Scale: 1.0
|
4 | 4 | 4 | 579 |
Scale: 1.0
|
14 | 15 | 15 | 1956 |
| 3 | 3 | 4 | 464 | |
| 8 | 8 | 8 | 1074 |
DNN super-resolution is crucial for fast AI pipeline processing. It allows to process multiple AI effects much faster due to smaller input frame.
As shown in the flowchart super-resolution consists of following steps:
- Scale base image down by some factor.
- Process small frame through AI pipelines to achieve much better performance.
- Scale processed frame back using DNN super-resolution.
PyHook uses PySimpleGUI to create graphical interface on Windows OS using Tkinter.
GUI consists of few elements:
- Menu bar, where user can change app settings, verify pipelines files, install pipelines requirements, update app and show information about it.
- In 64-bit version of PyHook there is also checkbox that allows to select 32-bit processes.
- Injection bar, where user can find given process automatically or by search bar using process name or id.
- Session list, where user can see all active/dead sessions. Each session have icon (if possible to get from .exe file by Windows API), executable name and process id. Active sessions have green border, dead are using red color.
- Session overview, where user can see live logs and timings (on screenshot below) from given session, kill it or restart (if it was stopped by any reason).
PyHook addon uses ReShade ImGui UI to display list of available pipelines and their respective settings.
To display pipeline list, open ReShade UI and go to Add-ons tab:
Settings for enabled pipelines are displayed below mentioned list:
Supported UI widgets (read more in pipeline template):
- Checkbox
- Slider (integer value)
- Slider (float value)
- Combo box (single value select)
ReShade >= 5.0.0
Python ==
3.10.6 for 64-bit* |3.10.4 for 32-bit(for pipelines only)CUDA >= 11.3** (optional for AI pipelines only)
cuDNN >= 8.4.1** (optional for AI pipelines only)
- Only for specific pipelines: Any libraries that are required by pipeline code.Do note that AI pipelines that requires PyTorch or TensorFlow will not work on 32-bit system because libraries does not support it.
- Same as runtime, but for ReShade addon only included headers are needed
- Boost == 1.80.0 (used for Boost.Interprocess shared memory)
- Dear ImGui == 1.86
- NumPy == 1.23.2
- Pillow == 9.2.0
- psutil == 5.9.2
- Pyinjector == 1.1.0
- PySimpleGUI == 4.60.3
- Requests == 2.28.1
- Same as build
- PyInstaller == 5.3
- Python Standard Library List == 0.8.0
You can download selected PyHook archives from Releases.
Download and unpack zip catalog with PyHook executable and pipelines. Releases up to 1.1.2 contains also
*.addonfile.- Prepare Python local environment (read more in Virtual environment) and download pipelines files if needed.Pipelines has own directories with
download.txtfile that has list of files to download. Files can be also downloaded from PyHook app menu. Start game with ReShade installed.
Start PyHook.exe.
For custom pipelines (e.g. AI ones) install requirements (manually or from PyHook app menu) and setup ENV variables or settings that points to Python3 binary in required version.
Available ENV variables (required up to 1.1.2, can be set in settings in newer versions):
LOCAL_PYTHON_32(path to 32-bit Python)LOCAL_PYTHON_64(path to 64-bit Python)LOCAL_PYTHON(fallback path if none of above is set)
Models for pipelines can be downloaded by links from download.txt that are supplied in their respective directory.
You can also download them automatically from PyHook Pipeline menu.
If antivirus detects PyHook as dangerous software add exception for it because it is due to DLL injection capabilities.
To build PyHook addon download Boost and place header files in Addon/include. Then open *.sln project in Visual Studio and build given release.
build.bat in Anaconda Prompt.If any Python package is missing try to update your conda environment and add conda-forge channel:
$ conda config --add channels conda-forgePyHook allows to freely use virtual environment from Anaconda.
To create virtual env (64-bit) u can use following commands in Anaconda Prompt:
$ conda create -n pyhook64env python=3.10.6 -y
$ conda activate pyhook64env
$ conda install pip -y
$ pip install -r any_pipeline.requirements.txt
$ conda deactivateFor 32-bit different Python version have to be used (no new version at the time of writing):
$ set CONDA_FORCE_32BIT=1 // Only for 64-bit system
$ conda create -n pyhook32env python=3.10.4 -y
$ conda activate pyhook32env
$ conda install pip -y
$ pip install -r any_pipeline.requirements.txt
$ conda deactivate
$ set CONDA_FORCE_32BIT= // Only for 64-bit systemWhen virtual environment is ready to be used, copy it's Python executable path and set system environment variables described in Installation.
- Anaconda for virtual environment
- CUDA >= 11.3 (pick last supported by your GPU and pipeline modules)
- cuDNN >= 8.4.1 (pick last supported by your CUDA version)
- Visual Studio >= 16 with C++ support
- git for version control
- CMake for source build
After installation make sure that following environment variables are set:
CUDA_PATH(e.g. "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3")PATHwith paths to CUDA + cuDNN and CMake, e.g.:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\bin""C:\Program Files\CMake\bin"
When requirements are set, run Anaconda Prompt and follow code from file: build_opencv_cuda.bat
After build new environment variables have to be set:
OpenCV_DIR(e.g. "C:\OpenCV\OpenCV-4.6.0")PATH, add path to OpenCV built binaries (e.g. "C:\OpenCV\OpenCV-4.6.0\x64\vc16\bin")OPENCV_LOG_LEVEL"ERROR", to suppress warning messages
build_opencv_cuda.bat has name opencv_build.>>> import cv2
>>> print(cv2.cuda.getCudaEnabledDeviceCount())
>>> print(cv2.getBuildInformation())OpenCV to PyHook. To do this setup LOCAL_PYTHON_64 env or setting to executable file from OpenCV virtual environment.>>> import sys
>>> print(sys.executable)
'C:\\Users\\xyz\\anaconda3\\envs







































评论