ByteTrack icon indicating copy to clipboard operation
ByteTrack copied to clipboard

AttributeError: 'STrack' object has no attribute '_count

Open feiyang-hku opened this issue 3 years ago • 17 comments

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 avatar Jun 25 '22 13:06 feiyang-hku

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!

feiyang-hku avatar Jun 25 '22 14:06 feiyang-hku

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

wangxiyang2022 avatar Jun 26 '22 12:06 wangxiyang2022

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.

feiyang-hku avatar Jun 26 '22 12:06 feiyang-hku

Thank you very much!

wangxiyang2022 avatar Jun 26 '22 13:06 wangxiyang2022

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!

Breezewrf avatar Jun 28 '22 02:06 Breezewrf

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

starhou avatar Jun 29 '22 08:06 starhou

you need to replace yolox with the previous version

JonathanFK981 avatar Jun 29 '22 15:06 JonathanFK981

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

LIN-HAN-981120 avatar Jun 30 '22 04:06 LIN-HAN-981120

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

PranvQT avatar Jul 01 '22 05:07 PranvQT

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

jasons1425 avatar Jul 03 '22 04:07 jasons1425

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'

Breezewrf avatar Jul 03 '22 05:07 Breezewrf

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 avatar Jul 03 '22 05:07 PranvQT

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

PranvQT avatar Jul 03 '22 05:07 PranvQT

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

Breezewrf avatar Jul 03 '22 06:07 Breezewrf

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 avatar Jul 03 '22 09:07 jasons1425

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.

nikky4D avatar Jul 06 '22 21:07 nikky4D

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 :)

jasons1425 avatar Jul 07 '22 04:07 jasons1425

Hi Yifu,

Thank you so much for your prompt reply!

I tried to add the line “self._count = 0” to byte_tracker.py as you have suggested. The code can now run, but the algorithm can only detect and track only one person (ID 1) in a scene full of people.

@.***

May I know what other steps I need to take if I want to detect and track all people in the scene?

Thanks again for your kind help!

Sincerely,

Feiyang

From: sr99622 @.> Date: Sunday, June 26, 2022 at 12:50 AM To: ifzhang/ByteTrack @.> Cc: feiyang-hku @.>, Author @.> Subject: Re: [ifzhang/ByteTrack] AttributeError: 'STrack' object has no attribute '_count (Issue #210)

For some reason, the inheritance doesn't work on this class, You can get around it by adding a reference In byte_tracker.py to _count in the STrack.init like so

class STrack(BaseTrack):

shared_kalman = KalmanFilter()

def __init__(self, tlwh, score):

    self._count = 0

— Reply to this email directly, view it on GitHubhttps://github.com/ifzhang/ByteTrack/issues/210#issuecomment-1166324063, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALV55KGVV2XY4FECOUBJHODVQ42DJANCNFSM5Z2KSRZA. You are receiving this because you authored the thread.Message ID: @.***>

feiyang-hku avatar Oct 11 '22 08:10 feiyang-hku