geekyutao / Inpaint-Anything

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

Torch.text.legacy not found #150

Open danishbansal808 opened 2 months ago

danishbansal808 commented 2 months ago

Hi I am trying to run remove_anything on google colab Here is the link https://colab.research.google.com/drive/1BcAdmCI7GXEsW_O4IfohFpuBOqL0K8wG?usp=sharing

But I am getting this error and not able to solve. Can anyone help?

/content/Inpaint-Anything/segment_anything/segment_anything/modeling/tiny_vit_sam.py:657: UserWarning: Overwriting tiny_vit_5m_224 in registry with segment_anything.modeling.tiny_vit_sam.tiny_vit_5m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/content/Inpaint-Anything/segment_anything/segment_anything/modeling/tiny_vit_sam.py:657: UserWarning: Overwriting tiny_vit_11m_224 in registry with segment_anything.modeling.tiny_vit_sam.tiny_vit_11m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/content/Inpaint-Anything/segment_anything/segment_anything/modeling/tiny_vit_sam.py:657: UserWarning: Overwriting tiny_vit_21m_224 in registry with segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/content/Inpaint-Anything/segment_anything/segment_anything/modeling/tiny_vit_sam.py:657: UserWarning: Overwriting tiny_vit_21m_384 in registry with segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_384. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/content/Inpaint-Anything/segment_anything/segment_anything/modeling/tiny_vit_sam.py:657: UserWarning: Overwriting tiny_vit_21m_512 in registry with segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_512. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
Traceback (most recent call last):
  File "/content/Inpaint-Anything/remove_anything.py", line 9, in <module>
    from lama_inpaint import inpaint_img_with_lama
  File "/content/Inpaint-Anything/lama_inpaint.py", line 19, in <module>
    from saicinpainting.evaluation.utils import move_to_device
  File "/content/Inpaint-Anything/lama/saicinpainting/evaluation/__init__.py", line 6, in <module>
    from saicinpainting.evaluation.losses.base_loss import SSIMScore, LPIPSScore, FIDScore
  File "/content/Inpaint-Anything/lama/saicinpainting/evaluation/losses/base_loss.py", line 15, in <module>
    from .lpips import PerceptualLoss
  File "/content/Inpaint-Anything/lama/saicinpainting/evaluation/losses/lpips.py", line 15, in <module>
    from saicinpainting.utils import get_shape
  File "/content/Inpaint-Anything/lama/saicinpainting/utils.py", line 12, in <module>
    from pytorch_lightning import seed_everything
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.functional.accuracy import _accuracy_compute, _accuracy_update
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/functional/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.functional.accuracy import accuracy  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/functional/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.classification.helpers import _input_format_classification, DataType
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/classification/helpers.py", line 19, in <module>
    from pytorch_lightning.metrics.utils import select_topk, to_onehot
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/metrics/utils.py", line 18, in <module>
    from pytorch_lightning.utilities import rank_zero_warn
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/apply_func.py", line 29, in <module>
    from torchtext.legacy.data import Batch
ModuleNotFoundError: No module named 'torchtext.legacy'

Note: Torchtext is already installed

Ashh-Z commented 2 months ago

Have you tried changing your pytorch lightning version ? I had faced the same issue on a different repository a while back, and changing the lightning version helped.