ealbasicvsr\miniconda3\lib\site-packages\mmcv_init_.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
warnings.warn(
usage: inference_realbasicvsr.py [-h] [--max_seq_len MAX_SEQ_LEN] [--is_save_as_png IS_SAVE_AS_PNG] [--fps FPS]
config checkpoint input_dir output_dir
inference_realbasicvsr.py: error: argument --max_seq_len: invalid int value: ''
Assistant
The error message:
inference_realbasicvsr.py: error: argument --max_seq_len: invalid int value: ''
means that the argument --max_seq_len was provided with an empty string as its value, which is not valid because it expects an integer.
What to check/fix:
Check the command you are running.
You probably have something like:
type fps of your input video here (default for demo video is 29.97):
type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality):
Assistant
The script you are running (likely inference_realbasicvsr.py) is prompting you to input two values interactively:
FPS (frames per second) of the input video
Default is 29.97 (which is a common frame rate for videos).
You can press Enter to accept the default or type a custom FPS value, e.g., 30.
max_seq_len
Default is 20.
This controls the maximum sequence length the model processes at once.
Lowering it can reduce VRAM/RAM usage but might impact output quality slightly.
You can accept the default by pressing Enter or enter a custom integer, e.g., .
User
@echo off
:set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:launch miniconda
call %DIR%\Scripts\activate.bat
:open folder with realbasicvsr
cd %~dp0RealBasicVSR
:make some interactive inputs
set /p fps=type fps of your input video here (default for demo video is 29.97):
set /p seq=type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality):
Thanks for sharing your batch script! The issue you are encountering stems from how you handle default values for the inputs fps and max_seq_len.
User
add value to low vram
Assistant
Got it! You want to add an option that sets max_seq_len to a lower value automatically if the user has low VRAM, possibly with a prompt or flag.
Here’s a quick way to add a prompt asking if the user wants to reduce VRAM usage, and if yes, set max_seq_len to a lower default (like 10 instead of 20):
@echo off
:: set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:: launch miniconda
call %DIR%\Scripts\activate.bat
:: open folder with RealBasicVSR
cd /d %~dp0RealBasicVSR
:: prompt: low VRAM option
set /p lowvram=Do you want to reduce VRAM usage? (y/N):
if /i "%lowvram%"=="y" (
set seq_default=10
) else (
set seq_default=20
)
:: make some interactive inputs
set /p fps=type fps of your input video here (default for demo video is 29.97):
if "%fps%"=="" set fps=29.97
set /p seq=type max_seq_len value (default is %seq_default%, but decreasing this may slightly reduce VRAM and RAM usage with a little loss of output quality):
if "%seq%"=="" set seq=%seq_default%
:: execute video upscaling script
python inference_realbasicvsr.py configs/realbasicvsr_x4.py checkpoints/RealBasicVSR_x4.pth data/input.mp4 data/output.mp4 --max_seq_len=%seq% --fps=%fps%
pause
User
automatic with value to low vram defined
Assistant
User
this example more with value to low vram: @echo off
:set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:launch miniconda
call %DIR%\Scripts\activate.bat
:open folder with realbasicvsr
cd %~dp0RealBasicVSR
:make some interactive inputs
set /p fps=type fps of your input video here (default for demo video is 29.97):
set /p seq=type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality):
If you're calling this script from a wrapper or shell command, check how the argument is passed and make sure it's a valid integer, not empty.
About the warning from MMCV
You also see this warning:
UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv.
This is just a warning telling you to be aware of major changes in mmcv starting from version 2.0.0. You can safely ignore it for now, but if you plan to upgrade mmcv in the future, check their compatibility notes.
Summary
Fix your command line to provide a valid integer for --max_seq_len.
Ignore the warning for now or update your code if you upgrade mmcv to v2.0+.
If you want me to check the exact command you're running or help you craft the correct command, please provide your command line.
15
How to proceed:
If running interactively:
Just type your value and press Enter for each prompt, or just press Enter to accept defaults:
type fps of your input video here (default for demo video is 29.97): [press Enter or type your FPS]
type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality): [press Enter or type a number]
If you want to avoid interactive prompts and pass values via command line instead, check the script usage. It likely supports optional args like:
Make sure to supply valid numbers for --fps and --max_seq_len. Your earlier error about --max_seq_len means you probably passed it without a value or with empty quotes.
If you want, you can share the exact command you are running or how you want to run it, and I can help you format it correctly!
Problem:
If the user presses Enter without typing anything, %fps% and/or %seq% will be empty strings. When you pass --max_seq_len=%seq%, that becomes --max_seq_len=, causing the error:
error: argument --max_seq_len: invalid int value: ''
Similarly for --fps=.
How to fix this:
Add logic in your batch script to assign default values when the user presses Enter without input.
Modify your script like this:
@echo off
:: set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:: launch miniconda
call %DIR%\Scripts\activate.bat
:: open folder with RealBasicVSR
cd /d %~dp0RealBasicVSR
:: make some interactive inputs
set /p fps=type fps of your input video here (default for demo video is 29.97):
if "%fps%"=="" set fps=29.97
set /p seq=type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality):
if "%seq%"=="" set seq=20
:: execute video upscaling script
python inference_realbasicvsr.py configs/realbasicvsr_x4.py checkpoints/RealBasicVSR_x4.pth data/input.mp4 data/output.mp4 --max_seq_len=%seq% --fps=%fps%
pause
Explanation of changes:
After each set /p input, you check if the variable is empty (""), then assign the default value.
This way, %fps% and %seq% always have a valid value (either user entered or default).
Also added /d to cd command to ensure it works across drives.
Optional: Add validation (optional but helpful)
You can also add some simple checks to verify input is numeric, but it's optional.
Summary:
This simple fix will avoid passing empty strings to your Python script arguments, preventing the "invalid int value" error.
If you want me to help you make the script more robust or add argument validation, just ask!
How it works:
Asks the user if they want to reduce VRAM usage (y means yes, anything else means no).
Sets the seq_default to 10 if low VRAM, else 20.
The prompt for max_seq_len shows the default accordingly.
If the user just presses Enter for max_seq_len, it uses the chosen default.
You can easily adjust:
The “reduced” value (here 10).
The regular default (here 20).
Let me know if you want it fully automatic or want to infer VRAM from the system or GPU!
To automatically set max_seq_len based on your system's VRAM (without any interactive prompt), you would need a way to detect your GPU’s VRAM amount from within the batch script or Python.
Unfortunately, native Windows batch scripting cannot easily detect GPU VRAM directly. But you have a few practical options:
Option 1: Detect VRAM using Python and then launch the inference script with appropriate max_seq_len
You can write a small Python snippet that:
Detects available GPU VRAM,
Sets the max_seq_len value accordingly,
Calls the inference script with that value.
Option 2: Approximate VRAM detection via nvidia-smi if you have an NVIDIA GPU and nvidia-smi installed.
Here's a practical combined solution using nvidia-smi called inside batch script:
Updated batch script:
@echo off
:: set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:: launch miniconda
call %DIR%\Scripts\activate.bat
:: open folder with RealBasicVSR
cd /d %~dp0RealBasicVSR
:: Try to detect total GPU VRAM in MB using nvidia-smi
FOR /F "usebackq tokens=3" %%v IN (`nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2^>nul`) DO set GPUMEM=%%v
if not defined GPUMEM (
echo Could not detect NVIDIA GPU VRAM - defaulting to max_seq_len = 20
set max_seq_len=20
) else (
echo Detected GPU VRAM: %GPUMEM% MB
REM set max_seq_len according to VRAM size thresholds (adjust thresholds as needed)
if %GPUMEM% LSS 4000 (
echo Low VRAM detected (<4GB): setting max_seq_len=10
set max_seq_len=10
) else if %GPUMEM% LSS 8000 (
echo Medium VRAM detected (<8GB): setting max_seq_len=15
set max_seq_len=15
) else (
echo High VRAM detected (>=8GB): setting max_seq_len=20
set max_seq_len=20
)
)
:: Ask for FPS or use default (29.97)
set /p fps=type fps of your input video here (default for demo video is 29.97):
if "%fps%"=="" set fps=29.97
:: Run python script with detected max_seq_len
python inference_realbasicvsr.py configs/realbasicvsr_x4.py checkpoints/RealBasicVSR_x4.pth data/input.mp4 data/output.mp4 --max_seq_len=%max_seq_len% --fps=%fps%
pause
Explanation:
The script uses nvidia-smi --query-gpu=memory.total (in MB) to get GPU VRAM.
Batch variable %GPUMEM% holds VRAM amount.
According to VRAM size, it sets max_seq_len automatically:
<4GB VRAM → max_seq_len=10
<8GB VRAM → max_seq_len=15
=8GB VRAM → max_seq_len=20 (default)
If nvidia-smi or GPU is not detected, defaults to max_seq_len=20.
Interactive prompt for FPS remains (can be removed or adapted similarly).
If you want to do it inside Python before running inference:
import torch
if torch.cuda.is_available():
props = torch.cuda.get_device_properties(0)
vram_gb = props.total_memory / (1024 ** 3)
print(f"Detected GPU VRAM: {vram_gb:.2f} GB")
if vram_gb < 4:
max_seq_len = 10
elif vram_gb < 8:
max_seq_len = 15
else:
max_seq_len = 20
else:
print("No CUDA GPU detected, using default max_seq_len=20")
max_seq_len = 20
print(f"Using max_seq_len={max_seq_len}")
# Then you can continue your inference call or script logic with this max_seq_len
You could modify your inference_realbasicvsr.py entry point to run this check and set defaults internally, then also accept command line override.
Summary
Best Windows batch workaround is nvidia-smi detection if NVIDIA GPU is present.
For other GPUs or more robust solution, do VRAM detection inside Python.
Automatically set max_seq_len based on VRAM value to optimize memory vs quality tradeoff.
If you want me to help modify your Python script for automatic VRAM detection or integrate the above functionality, just ask!
Certainly! Below is your batch script example enhanced to automatically set max_seq_len based on detected GPU VRAM (using nvidia-smi), with a fallback to your interactive input if detection fails, and with defined values for low VRAM cases:
@echo off
:: set necessary folders and paths to work like miniconda is installed
set DIR=%~dp0miniconda3
set appdata=%DIR%\wincache
set userprofile=%DIR%\wincache
set temp=%DIR%\wincache
set PATH=C:\Windows\system32;C:\Windows;%DIR%\git\bin;%DIR%;%DIR%\Scripts
set PY_LIBS=%DIR%\Lib;%DIR%\Lib\site-packages
set PY_PIP=%DIR%\Scripts
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
set TORCH_HOME=%DIR%\torch-cache
:: launch miniconda
call %DIR%\Scripts\activate.bat
:: open folder with RealBasicVSR
cd /d %~dp0RealBasicVSR
:: --- Try to detect total GPU VRAM in MB using nvidia-smi ---
FOR /F "usebackq tokens=3" %%v IN (`nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2^>nul`) DO set GPUMEM=%%v
if not defined GPUMEM (
echo Could not detect NVIDIA GPU VRAM - interactive input will be used for max_seq_len.
set use_interactive=1
) else (
echo Detected GPU VRAM: %GPUMEM% MB
set use_interactive=0
if %GPUMEM% LSS 4000 (
echo Low VRAM detected (<4GB): setting max_seq_len=10
set max_seq_len=10
) else if %GPUMEM% LSS 8000 (
echo Medium VRAM detected (<8GB): setting max_seq_len=15
set max_seq_len=15
) else (
echo High VRAM detected (>=8GB): setting max_seq_len=20
set max_seq_len=20
)
)
:: Ask for fps; default 29.97 if empty
set /p fps=type fps of your input video here (default for demo video is 29.97):
if "%fps%"=="" set fps=29.97
:: If GPU mem not detected, ask user for max_seq_len
if "%use_interactive%"=="1" (
set /p seq=type max_seq_len value (default is 20, but decreasing this may slightly reduce vram and ram usage with a little loss of output quality):
if "%seq%"=="" (
set seq=20
)
) else (
set seq=%max_seq_len%
echo Using max_seq_len=%seq% based on GPU VRAM detection.
)
:: Execute video upscaling script
python inference_realbasicvsr.py configs/realbasicvsr_x4.py checkpoints/RealBasicVSR_x4.pth data/input.mp4 data/output.mp4 --max_seq_len=%seq% --fps=%fps%
pause
How this works:
Attempts to detect GPU VRAM with nvidia-smi.
If detection succeeds, sets max_seq_len automatically based on VRAM tiers:
<4GB → 10
<8GB → 15
>=8GB → 20
If detection fails, asks user interactively for preferred max_seq_len with default 20.
Always asks for FPS with default 29.97 if left empty.
Prints what it is doing for transparency.
Notes:
This only works if you have an NVIDIA GPU and nvidia-smi available in PATH.
If you want fully automatic detection for other GPUs, you will need a Python-based approach.
You can easily customize the VRAM thresholds and default values as you wish.
Let me know if you want me to help implement a Python version of automatic VRAM detection and max_seq_len calculation!