From 578d31684888ebf2f7d1ae39863eee597bb83cc6 Mon Sep 17 00:00:00 2001 From: "LIU, Zichen" <64915812+zliucz@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:17:24 +0800 Subject: [PATCH] update Windows/Linux environment install --- README.md | 31 +++++++++++++++++--------- linux_setup.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++ windows_setup.bat | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 linux_setup.sh create mode 100644 windows_setup.bat diff --git a/README.md b/README.md index 749c44a..3b18485 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ There is an HD video on [Youtube](https://www.youtube.com/watch?v=5DiKfONMnE4). - [🪶 MagicQuill: An Intelligent Interactive Image Editing System](#-magicquill-an-intelligent-interactive-image-editing-system) - [TODO List](#todo-list) + - [Update Log](#update-log) - [Hardware Requirements](#hardware-requirements) - [Setup](#setup) - [Tutorial](#tutorial) @@ -35,6 +36,10 @@ There is an HD video on [Youtube](https://www.youtube.com/watch?v=5DiKfONMnE4). +## Update Log + +- [2024.11.21] Update the save button; Fix path bug on Windows; Add `.bat` and `.sh` files for convenient environment install on Windows and Linux. + ## Hardware Requirements - GPU is required to run MagicQuill. **Through our testing, we have confirmed that the model can run on GPUs with 8GB VRAM.** @@ -43,9 +48,9 @@ For users with limited GPU resources, please try our [Huggingface Demo](https:// ## Setup -If you are a Linux user, follow the following guide to set up the environment. If you are a Windows user, you may find [this](https://github.com/magic-quill/MagicQuill/issues/11) helpful. +Follow the following guide to set up the environment. -1. git clone repo +1. git clone repo. **Please don't forget the `--recursive` flag.** Otherwise, you will find `LLaVA` submodule missing. ``` git clone --recursive https://github.com/magic-quill/MagicQuill.git cd MagicQuill @@ -57,21 +62,27 @@ If you are a Linux user, follow the following guide to set up the environment. I ``` If the .zip file is not accessible, download it via browser. All checkpoints are about 25 GB in total. It may take some time to download. Alternatively, check our checkpoints at [huggingface](https://huggingface.co/LiuZichen/MagicQuill-models). +--- + +If you are a Windows user, you may try to use `windows_setup.bat` to conveniently install environments. For Linux user, check `linux_setup.sh`. + +Alternatively, follow the step-by-step installation guide. + 3. create environment ``` conda create -n MagicQuill python=3.10 -y conda activate MagicQuill ``` -4. install the interface - ``` - pip install gradio_magicquill-0.0.1-py3-none-any.whl - ``` - -5. install torch with GPU support +4. install torch with GPU support ``` pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118 ``` + +5. install the interface + ``` + pip install gradio_magicquill-0.0.1-py3-none-any.whl + ``` 6. install llava environment ``` @@ -87,12 +98,12 @@ If you are a Linux user, follow the following guide to set up the environment. I ``` -8. install the remaining environment +7. install the remaining environment ``` pip install -r requirements.txt ``` -9. run magicquill +8. run magicquill ``` python gradio_run.py ``` diff --git a/linux_setup.sh b/linux_setup.sh new file mode 100644 index 0000000..bfb9221 --- /dev/null +++ b/linux_setup.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +CONDA_PATH=$(conda info --base) +source "$CONDA_PATH/etc/profile.d/conda.sh" + +# Create conda environment if it doesn't exist +if ! conda env list | grep -q "MagicQuill"; then + echo "Creating conda environment MagicQuill..." + conda create -n MagicQuill python=3.10 -y + + # Initialize conda after creating new environment + echo "Initializing conda..." + conda init bash + + echo "Environment created. Please run this script again to continue installation." + exit 0 +fi + +# Activate conda environment +echo "Activating conda environment..." +conda activate MagicQuill + +# Install PyTorch with CUDA 11.8 +echo "Installing PyTorch 2.1.2 with CUDA 11.8..." +pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118 + +# Verify PyTorch installation and CUDA availability +python -c "import torch; print('PyTorch version:', torch.version); print('CUDA available:', torch.cuda.is_available())" +if [ $? -ne 0 ]; then + echo "Failed to install or verify PyTorch" + exit 1 +fi + +# Install the required interface package +echo "Installing gradio_magicquill..." +pip install gradio_magicquill-0.0.1-py3-none-any.whl + +# Install the llava environment +echo "Setting up LLaVA environment..." +if [ ! -d "MagicQuill/LLaVA" ]; then + echo "Directory MagicQuill/LLaVA does not exist. Ensure the folder structure is correct." + exit 1 +fi +cp -f pyproject.toml MagicQuill/LLaVA/ +pip install -e MagicQuill/LLaVA/ + +# Install remaining dependencies +echo "Installing additional requirements..." +pip install -r requirements.txt + +# Run MagicQuill +echo "Starting MagicQuill..." +export CUDA_VISIBLE_DEVICES=0 +python gradio_run.py || { + echo "Error: Failed to run MagicQuill." + exit 1 +} \ No newline at end of file diff --git a/windows_setup.bat b/windows_setup.bat new file mode 100644 index 0000000..32909cf --- /dev/null +++ b/windows_setup.bat @@ -0,0 +1,56 @@ +:: Create conda environment if it doesn't exist +conda env list | find "MagicQuill" >nul 2>nul +if %ERRORLEVEL% NEQ 0 ( +echo Creating conda environment MagicQuill... +call conda create -n MagicQuill python=3.10 -y + +:: Initialize conda after creating new environment +echo Initializing conda... +call conda init cmd.exe + +echo Environment created. Please run this script again to continue installation. +pause +exit /b 0 +) + +:: Activate conda environment +echo Activating conda environment... +call conda activate MagicQuill + +:: Install PyTorch with CUDA 11.8 +echo Installing PyTorch 2.1.2 with CUDA 11.8... +pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118 + +:: Verify PyTorch installation and CUDA availability +python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available())" +if %ERRORLEVEL% NEQ 0 ( +echo Failed to install or verify PyTorch +pause +exit /b 1 +) + +:: Install the required interface package +echo Installing gradio_magicquill... +pip install gradio_magicquill-0.0.1-py3-none-any.whl + +:: Install the llava environment +echo Setting up LLaVA environment... +if not exist MagicQuill\LLaVA ( +echo Directory MagicQuill\LLaVA does not exist. Ensure the folder structure is correct. +exit /b 1 +) +copy /y pyproject.toml MagicQuill\LLaVA +pip install -e MagicQuill\LLaVA\ + +:: Install remaining dependencies +echo Installing additional requirements... +pip install -r requirements.txt + +:: Run MagicQuill +echo Starting MagicQuill... +set CUDA_VISIBLE_DEVICES=0 +python gradio_run.py || ( +echo Error: Failed to run MagicQuill. +pause +exit /b 1 +) \ No newline at end of file