hustvl / Matte-Anything

[Image and Vision Computing (Vol.147 Jul. '24)] Interactive Natural Image Matting with Segment Anything Models
MIT License
465 stars 33 forks source link

Incorrect dependency of requirements:gradio #20

Closed TonyDua closed 3 months ago

TonyDua commented 3 months ago

In the requirements.txt file, it is written:

torch==2.0.0
torchvision
tensorboard
timm==0.5.4
opencv-python==4.5.3.56
setuptools==58.2.0
easydict
wget
scikit-image
gradio
fairscale

Firstly, opencv-python==4.5.3.56 fails to compile in a Windows conda virtual environment with Python version 3.9.19 and CUDA version 11.8. But executing ‘pip install opencv-python’ directly solves the problem.

Secondly, pip install gradio in the aforementioned environment version, installs version 4.26.0 by default. Executing python matte_anything.py results in the following error:

Traceback (most recent call last):
  File "C:\Matte-Anything\matte_anything.py", line 309, in <module>
    with gr.Row().style(equal_height=True):
         ^^^^^^^^^^^^^^
AttributeError: 'Row' object has no attribute 'style'
IMPORTANT: You are using gradio version 4.26.0, however version 4.29.0 is available, please upgrade.

So, I uninstalled gradio and installed the latest version 4.29.0, but the problem persisted. Since there is no mention of the gradio version in your readme.md, after googling, I found a similar issue in another GitHub repository, suggesting the use of version 3.50.0. Therefore, I switched to gradio version 3.50.0.

Thank goodness, it finally executed, and the webpage opened. However, when selecting foreground and background points, I noticed that clicking on the image area had no effect, and a large number of errors appeared in the terminal.

image

So, I'd like to ask which version of gradio and Python you are using. Thank you again for your hard work. I really want to try it out, please help!

YeL6 commented 3 months ago

In the requirements.txt file, it is written:

torch==2.0.0
torchvision
tensorboard
timm==0.5.4
opencv-python==4.5.3.56
setuptools==58.2.0
easydict
wget
scikit-image
gradio
fairscale

Firstly, opencv-python==4.5.3.56 fails to compile in a Windows conda virtual environment with Python version 3.9.19 and CUDA version 11.8. But executing ‘pip install opencv-python’ directly solves the problem.

Secondly, pip install gradio in the aforementioned environment version, installs version 4.26.0 by default. Executing python matte_anything.py results in the following error:

Traceback (most recent call last):
  File "C:\Matte-Anything\matte_anything.py", line 309, in <module>
    with gr.Row().style(equal_height=True):
         ^^^^^^^^^^^^^^
AttributeError: 'Row' object has no attribute 'style'
IMPORTANT: You are using gradio version 4.26.0, however version 4.29.0 is available, please upgrade.

So, I uninstalled gradio and installed the latest version 4.29.0, but the problem persisted. Since there is no mention of the gradio version in your readme.md, after googling, I found a similar issue in another GitHub repository, suggesting the use of version 3.50.0. Therefore, I switched to gradio version 3.50.0.

Thank goodness, it finally executed, and the webpage opened. However, when selecting foreground and background points, I noticed that clicking on the image area had no effect, and a large number of errors appeared in the terminal.

image

So, I'd like to ask which version of gradio and Python you are using. Thank you again for your hard work. I really want to try it out, please help!

Thank you for your interest in our work! We appreciate your question!

About the code you gave us, we believe the issue might be due to an update in the gradio version. I checked the original code, which uses version 3.34.0. You might try using pip install gradio==3.34.0 to match the environment with the original setup.

I hope this works for you! If you have any other questions, we will be sure to continue to help you.

TonyDua commented 3 months ago

@YeL6 Thank you for your guidance!

I also tried updating the relevant code in matte_anything.py to meet the requirements of the latest gradio version. The main modification was changing withgr.Row().style(equal_height=True):togr.Row()., as gradio removed the style attribute. Additionally, I removed gr.input and changed the default variable of all controls to value. Now, this script runs well in the latest gradio version.

I'm not sure if your team has any compatibility plans for the latest version of gradio, so I didn't rush to submit a PR.

1.According to @YeL6's reply, execute the following commands:

pip uninstall gradio
pip install gradio==3.34.0

2.If you want to use the latest version of gradio: Follow the above method to modifymatte_anything.py. I'm sorry GitHub doesn't allow inserting .py files in replies, so I can't paste it here.

Finally, I suggest considering updating the code to be compatible with the latest version of gradio, or allowing me to submit a PR. Thank you!

YeL6 commented 3 months ago

@TonyDua Thank you very much for your contribution! This will be of great help to the users of matte-anything!

On the other hand, projects can indeed encounter issues due to updates of different packages. To address this, we currently plan to specify the corresponding package versions in the requirements.txt file. In the future, we will strive to provide more comprehensive updates. Thank you for your attention.

TonyDua commented 3 months ago

@YeL6 Thank you! Looking forward to future updates!