-1

I am trying to run my script but I am getting the following error, and i don't know what is the circular import which is the cause of this error, can anyone fix this pls

AttributeError Traceback (most recent call last) Input In [5], in <cell line: 1>()

---> 1 from inference import convert_video
      3 convert_video(
      4     model,                           # The model, can be on any device (cpu or cuda).
      5     input_source=r"C:\Users\alaba\Desktop\RobustVideoMatting-master\test.mp4",    

A video file or an image sequence directory.

(...) 12 seq_chunk=12, # Process n frames at once for better parallelism. 13 )

File ~\Desktop\RobustVideoMatting-master\inference.py:22, in 19 from typing import Optional, Tuple 20 from tqdm.auto import tqdm ---> 22 from inference_utils import VideoReader, VideoWriter, ImageSequenceReader, ImageSequenceWriter 24 def convert_video(model, 25 input_source: str, 26 input_resize: Optional[Tuple[int, int]] = None, (...) 36 device: Optional[str] = None, 37 dtype: Optional[torch.dtype] = None): 39 """ 40 Args: 41 input_source:A video file, or an image sequence directory. Images must be sorted in accending order, support png and jpg. (...) 55 dtype: Only need to manually provide if model is a TorchScript freezed model. 56 """

File ~\Desktop\RobustVideoMatting-master\inference_utils.py:3, in

    1 import av
      2 import os
----> 3 import pims
      4 import numpy as np
      5 from torch.utils.data import Dataset

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pims_init_.py:1, in ----> 1 from pims.api import * 3 from ._version import get_versions 4 version = get_versions()['version']

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pims\api.py:33, in

     31 try:
     32     import pims.pyav_reader
---> 33     if pims.pyav_reader.available():
     34         PyAVReaderTimed = pims.pyav_reader.PyAVReaderTimed
     35         PyAVReaderIndexed = pims.pyav_reader.PyAVReaderIndexed

AttributeError: partially initialized module 'pims' has no attribute 'pyav_reader' (most likely due to a circular import)

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Ala BR
  • 49
  • 1
  • 6
  • Well I have solved this problem by installing another version of pims (v0.5), but it gave another error : ImportError: cannot import name 'Iterable' from 'collections' (C:\Users\alaba\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py), and this error came from importing pims.api – Ala BR Jul 13 '22 at 09:51

1 Answers1

0

Solved by installing a different version of pims==0.5

Ala BR
  • 49
  • 1
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 14 '22 at 06:28