GaParmar / img2img-turbo

One-step image-to-image with Stable Diffusion turbo: sketch2image, day2night, and more
MIT License
1.61k stars 184 forks source link

Does it work on a Windows machine? #5

Closed joansc closed 7 months ago

joansc commented 7 months ago

Hello,

I wonder if img2img-turbo can work on a Windows machine since I see that triton library is needed. Also, will it work on Python 3.9 or 3.11 instead of 3.10?

Thanks,

Joan

junyanz commented 7 months ago

We haven't tested the code on Windows. Feel free to try it.

shodanx2 commented 7 months ago

Hello

Seems to work, here are my findings

image

You will have to create the outputs folder, or it will fail

md outputs

On windows here is the test command

python src/inference_paired.py --model_name "edge_to_image" --input_image "assets\examples\bird.png" --prompt "a blue bird" --output_dir "outputs"

My system is an uncertain state as I had previously installed python and some packages prior

As per https://github.com/VAST-AI-Research/TripoSR/issues/40 first post instructions

I have created with batch one-liner to test if you have the packages installed

@echo off & for /f "tokens=2* delims=-" %i in (environment.yaml) do ( for /f "tokens=1 delims=<>=@" %j in ("%i") do ( python -c "import sys; exec('try: import %j; sys.exit(0)\nexcept ImportError: sys.exit(1)')" && echo %j: OK || echo %j: missing ) )

Here is my current output on a functionning system

turbo: missing
 pytorch: missing
 defaults: missing
 python: missing
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1
    try: import  pip:; sys.exit(0)
                    ^
SyntaxError: invalid syntax
 pip:: missing
 clip : OK
 einops: OK
 numpy: OK
 open: missing
 opencv: missing
 pillow: missing
 scipy: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 timm: OK
 tokenizers: OK
 torch: OK
 torchaudio: OK
 torchdata: OK
 torchmetrics: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 torchvision: OK
 tqdm: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 transformers: OK
 triton: missing
 urllib3: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 xformers: OK
 streamlit: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 lpips: OK
 clean: missing
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
 peft: OK
 dominate: OK
 diffusers: OK
 gradio: OK

Some of these packages have imports different than the package name, for instance opencv-python is called cv2 and triton is in fact tritonclient.http

Also clean-fid is actually called cleanfid because python libs can't have dash in their name, why did they call it clean-fid is beyond me

Also open-clip-torch is called open_clip

You can test for those like this

@echo off & for %i in (tritonclient.http tritonclient.grpc cv2 cleanfid open_clip ) do ( for /f "tokens=1 delims=<>=@" %j in ("%i") do ( python -c "import sys; exec('try: import %j; sys.exit(0)\nexcept ImportError: sys.exit(1)')" && echo %j: OK || echo %j: missing ) )

Should return

tritonclient.http: OK
tritonclient.grpc: OK
cv2: OK
cleanfid: OK
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  _torch_pytree._register_pytree_node(
open_clip: OK

If you follow the instruction from my previous post

then do

pip install clip numpy open-clip-torch opencv-python pillow timm torch torchdata torchmetrics triton[all] xformers lpips clean-fid peft dominate diffusers

then run

@echo off & for /f "tokens=2* delims=-" %i in (environment.yaml) do ( for /f "tokens=1 delims=<>=@" %j in ("%i") do ( python -c "import sys; exec('try: import %j; sys.exit(0)\nexcept ImportError: sys.exit(1)')" && echo %j: OK || echo %j: missing ) )

@echo off & for  %i in (tritonclient.http tritonclient.grpc cv2 cleanfid open_clip ) do ( for /f "tokens=1 delims=<>=@" %j in ("%i") do ( python -c "import sys; exec('try: import %j; sys.exit(0)\nexcept ImportError: sys.exit(1)')" && echo %j: OK || echo %j: missing ) )

compare the outputs

then run

md outputs

python src/inference_paired.py --model_name "edge_to_image" --input_image "assets\examples\bird.png" --prompt "a blue bird" --output_dir "outputs"

Once you have the bird.png open and confirmed working

You can try the UI by typing

gradio gradio_sketch2image.py

and heading your browser to

http://127.0.0.1:7860

And yeah, that works great actually

image

joansc commented 7 months ago

Amazing, I also got it working on Windows 11 and using Python 3.11 !! Thanks for the detailed explanation.