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

what is the target means in def forward(self, img, target=None) #3

Open
john81923 opened this issue Oct 25, 2022 · 1 comment
Open

Comments

@john81923
Copy link

def forward(self, img, target=None):

what does the target stand for in this function argument?
Is there a sample or description?
thanks

@john81923 john81923 changed the title "def forward(self, img, target="def forward(self, img, target=" what is the target in def forward(self, img, target=None) Oct 25, 2022
@john81923 john81923 changed the title what is the target in def forward(self, img, target=None) what is the target means in def forward(self, img, target=None) Oct 25, 2022
@taohan10200
Copy link
Owner

The target is a dict packaged from the annotation, you can find its specific meaning in this script dataset.py

def HT21_ImgPath_and_Target(base_path,i):
    img_path = []
    labels=[]
    root  = osp.join(base_path, i + '/img1')
    img_ids = os.listdir(root)
    img_ids.sort()
    gts = defaultdict(list)
    with open(osp.join(root.replace('img1', 'gt'), 'gt.txt'), 'r') as f:
        lines = f.readlines()
        for lin in lines:
            lin_list = [float(i) for i in lin.rstrip().split(',')]
            ind = int(lin_list[0])
            gts[ind].append(lin_list)
    for img_id in img_ids:
        img_id = img_id.strip()
        single_path = osp.join(root, img_id)
        annotation  = gts[int(img_id.split('.')[0])]
        annotation = torch.tensor(annotation,dtype=torch.float32)
        box = annotation[:,2:6]
        points =   box[:,0:2] + box[:,2:4]/2
        sigma = torch.min(box[:,2:4], 1)[0] / 2.
        ids = annotation[:,1].long()
        img_path.append(single_path)
        labels.append({'scene_name':i,'frame':int(img_id.split('.')[0]), 'person_id':ids, 'points':points,'sigma':sigma})
    return img_path, labels

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

No branches or pull requests

2 participants