geekyutao / Inpaint-Anything

Inpaint anything using Segment Anything and inpainting models.
Apache License 2.0
6.4k stars 525 forks source link

Import error ModuleNotFoundError: No module named 'torchtext.legacy' caused by incompatibility issue #107

Open oddmanru opened 1 year ago

oddmanru commented 1 year ago

Hi there, I am trying to run this script on Googles Colab. I have encountered import error showing: "ModuleNotFoundError: No module named 'torchtext.legacy'" when the code attempted to import the Batch class using "from torchtext.legacy.data import Batch". After going through some investigation, I secured the issue that might be the incompatibility between the current torch-lightening and torchtext as the Batch class was deprecated and was fully replaced with torch's DataLoader. Moreover, it seems that the Batch class did not be used for loading batched data in Lama but it is part of code of metrics. Is there any quick fix for this issue? Or Can an updated version of torch-ligthening works well with this script?

Thanks.

CREED404 commented 10 months ago

installing python 3.8 solved this for me

rkuo2000 commented 10 months ago

python v3.10.12 torch v2.0.0 torchtext v0.15.1 torchdata v0.6.0

!python remove_anything.py

ModuleNotFoundError: No module named 'torchtext.legacy'

KUOFKING commented 6 months ago

!pip uninstall -y torchtext !pip install torchtext==0.5.0 this is work for me

rkuo2000 commented 6 months ago

!pip uninstall -y torchtext !pip install torchtext==0.5.0 this is work for me

Yes, it works. Thanks !

Chirilla commented 5 months ago

!pip uninstall -y torchtext !pip install torchtext==0.5.0 this is work for me

Yes, it works. Thanks !

Hi, sorry to bother you but I have the same problem with torchtex.legacy on colab and even tiwh torchtext==0.5.0 it doesn't work... Do you have any advice or notebook that works?? Thank you in advance

rkuo2000 commented 4 months ago

try pip install torchtext==0.10.0

andrecqcastro commented 4 months ago

try pip install pytorch-lightning==1.8.3.post0

https://github.com/Stability-AI/stablediffusion/issues/8