Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'STrack' object has no attribute '_count #210

Open
feiyang-hku opened this issue Jun 25, 2022 · 18 comments · May be fixed by #215
Open

AttributeError: 'STrack' object has no attribute '_count #210

feiyang-hku opened this issue Jun 25, 2022 · 18 comments · May be fixed by #215

Comments

@feiyang-hku
Copy link

Traceback (most recent call last):
File "tools/demo_track.py", line 372, in
main(exp, args)
File "tools/demo_track.py", line 365, in main
imageflow_demo(predictor, vis_folder, current_time, args)
File "tools/demo_track.py", line 263, in imageflow_demo
online_targets = tracker.update(outputs[0], [img_info['height'], img_info['width']], exp.test_size)
File "/content/ByteTrack/yolox/tracker/byte_tracker.py", line 268, in update
track.activate(self.kalman_filter, self.frame_id)
File "/content/ByteTrack/yolox/tracker/byte_tracker.py", line 48, in activate
self.track_id = self.next_id()
File "/content/ByteTrack/yolox/tracker/basetrack.py", line 36, in next_id
self._count += 1
AttributeError: 'STrack' object has no attribute '_count'

@feiyang-hku
Copy link
Author

Something seems to be wrong with the code...I was able to run the code yesterday. But today this error message popped out. I have tried creating a new conda environment and installed the dependencies again but is facing the same problem. Please help!

@wangxiyang2022
Copy link

Hello, may I ask whether this problem has been solved? I have also encountered this problem.

@feiyang-hku
Copy link
Author

I was able to work around it by git cloning from an older commit (The one on May 13, 2022). Please see this post for your reference. The command to git clone from an older commit can be found at https://stackoverflow.com/questions/3555107/git-clone-particular-version-of-remote-repository.

@wangxiyang2022
Copy link

Thank you very much!

qfgaohao added a commit to qfgaohao/ByteTrack that referenced this issue Jun 27, 2022
ifzhang#210

Fix for Issue: AttributeError: 'STrack' object has no attribute '_count ifzhang#210. ifzhang#210

Add base class initialization.
@Breezewrf
Copy link

I was able to work around it by git cloning from an older commit (The one on May 13, 2022). Please see this post for your reference. The command to git clone from an older commit can be found at https://stackoverflow.com/questions/3555107/git-clone-particular-version-of-remote-repository.

THX!

@starhou
Copy link

starhou commented Jun 29, 2022

@我也遇到了这个问题,当前该问题还在主干上存在,需要提交PR来解决一下 @feiyang-hku @iFighting

@JonathanFK981
Copy link

you need to replace yolox with the previous version

@LIN-HAN-981120
Copy link

you need to replace yolox with the previous version
how can i do that? thx!

Aspirinkb added a commit to Aspirinkb/ByteTrack that referenced this issue Jun 30, 2022
修改STrack class初始化方法,在其初始化方法中,调用父类BaseTrack的初始化方法。修正[bug 210](ifzhang#210)
@Aspirinkb Aspirinkb linked a pull request Jun 30, 2022 that will close this issue
@PranvQT
Copy link

PranvQT commented Jul 1, 2022

You have to add the super().init in the STrack so it can access the baseclass variables

@jasons1425
Copy link

I think this issue cannot be simply resolved by adding the super().init() method in the STrack class. Doing so seems to lead to issue #219. Checking out at the previous commit seems to be a better option in the current stage. My script works fine at the previous commit 2c082be

@Breezewrf
Copy link

I think this issue cannot be simply resolved by adding the super().init() method in the STrack class. Doing so seems to lead to issue #219. Checking out at the previous commit seems to be a better option in the current stage. My script works fine at the previous commit 2c082be

hello I have met the same problem that only single box is output, could you please tell me some details about your solution? since I checkout the commit 2c082be, but it seems can't work, still return _'STrack' object has no attribute 'count'

@PranvQT
Copy link

PranvQT commented Jul 3, 2022

Hi @Breezewrf the _count variable is not useful..what I did was I created a self.id_count for the bytetracker class and then passed it as an argument to the function call where we creat the new tracks and assigned that self.id_counter to the track_ID and then incremented the variable

@PranvQT
Copy link

PranvQT commented Jul 3, 2022

Yes @jasons1425 you are right I faced the same issue but I added a new variable for counting the objects so that got resolved.

@Breezewrf
Copy link

Hi @Breezewrf the _count variable is not useful..what I did was I created a self.id_count for the bytetracker class and then passed it as an argument to the function call where we creat the new tracks and assigned that self.id_counter to the track_ID and then incremented the variable

Thanks a lot! problem got resolved

@jasons1425
Copy link

Thank you @PranvQT. The problem is likely because each STrack object has its own track_id counting instead of the class-level one, so different tracks for the same ByteTracker object are sharing the same track_id.

To count the number of tracks in each ByteTracker object without relying on the BaseTrack class attributes, I have added an itertools.count() as the STrack counter inside the ByteTracker class. This argument is passed to the BaseTrack class so that whenever the next_id() method is called, the latest track id (count) can be fetched from this generator.

@nikky4D
Copy link

nikky4D commented Jul 6, 2022

I'm new to bytetrack. Can I see your code to see what changes should be made to get it to run over a video

Thank you @PranvQT. The problem is likely because each STrack object has its own track_id counting instead of the class-level one, so different tracks for the same ByteTracker object are sharing the same track_id.

To count the number of tracks in each ByteTracker object without relying on the BaseTrack class attributes, I have added an itertools.count() as the STrack counter inside the ByteTracker class. This argument is passed to the BaseTrack class so that whenever the next_id() method is called, the latest track id (count) can be fetched from this generator.

@jasons1425
Copy link

I didn't make many changes honestly. Just added a counter to count the track ids for each ByteTracker. You can find the changes in this pull request.

The modified scripts work fine in my local environment, but I would recommend you to just pull the main branch which has been recently reverted to get rid of this issue :)

@feiyang-hku
Copy link
Author

feiyang-hku commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants