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
How to train my own data? #36
Comments
Are they in COCO format? I.e., can you load them with the pycocotools API? |
Can you explain in details, please? I annotate my own data with coco annotator, i create new config file as coco-kp.yaml and yolov5s6.yaml but don't create kp_labels.
|
Can you share your config file and your dataset file structure please. |
Thanks for reply my question. I tried creating my dataset like coco.
airplane |
Interesting application. I'm assuming your jsons contain your custom labels in the COCO format? Try pulling the code, delete kp_labels directory, rename
|
I getting this error message.
|
Can you pull and try again please? |
I deleted all files of kapao and new created environment on anaconda. I cloned kapao again. I rearranged .yaml, yolov5s6.yaml and dataset. But I getting same error. Structure of created kp_labels: kp_labels And inside my .json:
|
What is problem? Annotations, is it possible? |
It wasn’t the same error. Look at the error: [Errno 2] No such file or directory: 'data/datasets/plane/images/val2017/hpron190000.jpg' |
If you send me a zip file with your images and annotations to wmcnally@uwaterloo.ca I can take a look at it. |
I noticed that error and fixed it later. The current error is the same as yesterday.
|
Ok. I will send zip. |
You need to change the filenames to the image ids (for the image files as well as in the annotation jsons). This needs to be done at least for the validation / test images. After I did that it worked for me. I also added the option to adjust the OKS sigmas in the config file with: For reference, I will email you back the files with the modifications. Please pull the code and try again after changing the filenames in the jsons and the |
I downloaded your data.zip that you sending and I run train.py with it. My train command:
Error that I getting:
|
Also, I try again after changing the filenames in the jsons and the images folder. But i getting error that same as yesterday.
What is cause of errors? Is Coco-Annotator? |
Your environment is using crowdposetools and I’m not sure why. It should be using pycocotools. Please ensure that COCOEval is being imported from pycocotools, not crowdposetools. |
I deleted my environment on conda. I created again new environment. Training is working now but metrics aren't working. I use this command for video:
|
The precision and recall metrics are not computed for human pose estimation so you can ignore them. If you're still only using 3 training images, I'm not surprised that your mAP is 0. To check if you can at least overfit your training data, you should use the training dataset for validation as well. To save the inference video remove the |
I see. I increased number of images in my dataset. But I getting this error now! I getting error at different percentage for different video. Also I getting error on inference of image.
|
You have to pass the config file with the |
Sorry! But it is not worked to me.
|
Do you have segments defined in your config file? Again, please try to debug before posting. Thanks! |
Thank you so much, really. I put too much indentation in the segment part in config file. I correct it then it works. |
Hi # train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
path: /home/omid/OMID/projects/python/draft/kapao/data/datasets/front_background1/coco
labels: kp_labels
train: kp_labels/img_txt/train2017.txt
val: kp_labels/img_txt/val2017.txt
test: kp_labels/img_txt/test2017.txt
train_annotations: /home/omid/OMID/projects/python/draft/kapao/utils/Dataset-6.json
val_annotations: /home/omid/OMID/projects/python/draft/kapao/utils/Dataset-6.json
test_annotations: /home/omid/OMID/projects/python/draft/kapao/utils/Dataset-6.json
pose_obj: True # write pose object labels
nc: 5 # number of classes (person class + 17 keypoint classes)
num_coords: 8 # number of keypoint coordinates (x, y)
# class names
names: [ "gate","top-left", "top-right", "bottom-left", "bottom-right" ]
kp_bbox: 0.05 # keypoint object size (normalized by longest img dim)
kp_flip: [] # for left-right keypoint flipping
kp_left: [] # left keypoints
kp_face: []
kp_names_short:
0: 'tl'
1: 'tr'
2: 'bl'
3: 'br'
# segments for plotting
segments:
1: [1, 2]
2: [1, 3]
3: [2, 4]
4: [3, 4]
I create label txt files with utils/labels.py and an example of the file is : 0 0.518229 0.469444 0.555208 0.744444 0.289583 0.148611 2.000000 0.757292 0.181944 2.000000 0.261458 0.770833 2.000000 0.723958 0.806944 2.000000
1 0.289583 0.148611 0.050000 0.066667 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
2 0.757292 0.181944 0.050000 0.066667 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
3 0.261458 0.770833 0.050000 0.066667 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
4 0.723958 0.806944 0.050000 0.066667 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 The problem is when I want to run the code with these configs and labels, I see this error: train.py --img 1280 --batch 8 --epochs 500 --data data/coco-kp-draft.yaml --hyp data/hyps/hyp.kp-p6.yaml --val-scales 1 --val-flips -1 --weights yolov5s6.pt --project runs/s_e500 --name train
train: weights=yolov5s6.pt, cfg=, data=data/coco-kp-draft.yaml, hyp=data/hyps/hyp.kp-p6.yaml, epochs=500, batch_size=8, imgsz=1280, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, adam=False, sync_bn=False, workers=8, project=runs/s_e500, entity=None, name=train, exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias=latest, local_rank=-1, freeze=0, patience=100, val_scales=[1.0], val_flips=[-1], autobalance=False
YOLOv5 🚀 ad507c2 torch 1.9.1+cu102 CUDA:0 (NVIDIA GeForce RTX 2070, 7982.3125MB)
hyperparameters: lr0=0.01, lrf=0.2, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw=1.0, kp=0.025, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.9, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, kp_bbox=0.05
TensorBoard: Start with 'tensorboard --logdir runs/s_e500', view at http://localhost:6006/
wandb: Currently logged in as: omiderfanmanesh-altran (use `wandb login --relogin` to force relogin)
wandb: wandb version 0.12.17 is available! To upgrade, please run:
wandb: $ pip install wandb --upgrade
wandb: Tracking run with wandb version 0.12.6
wandb: Syncing run train
wandb: View project at https://wandb.ai/omiderfanmanesh-altran/s_e500
wandb: View run at https://wandb.ai/omiderfanmanesh-altran/s_e500/runs/2ojfm3oe
wandb: Run data is saved locally in /home/omid/OMID/projects/python/draft/kapao/wandb/run-20220526_154421-2ojfm3oe
wandb: Run `wandb offline` to turn off syncing.
Overriding model.yaml nc=80 with nc=13
autoanchor: Analyzing anchors... anchors/target = 6.07, Best Possible Recall (BPR) = 1.0000
Image sizes 1280 train, 1280 val
Using 8 dataloader workers
Logging results to runs/s_e500/train29
Starting training for 500 epochs...
Epoch gpu_mem box obj cls kps labels img_size
0% 0/21 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/omid/OMID/projects/python/draft/kapao/train.py", line 601, in <module>
main(opt)
File "/home/omid/OMID/projects/python/draft/kapao/train.py", line 499, in main
train(opt.hyp, opt, device)
File "/home/omid/OMID/projects/python/draft/kapao/train.py", line 289, in train
for i, (imgs, targets, paths, _) in pbar: # batch -------------------------------------------------------------
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/tqdm/std.py", line 1195, in __iter__
for obj in iterable:
File "/home/omid/OMID/projects/python/draft/kapao/utils/datasets.py", line 148, in __iter__
yield next(self.iterator)
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
data = self._next_data()
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/_utils.py", line 425, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/omid/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
return self.collate_fn(data)
File "/home/omid/OMID/projects/python/draft/kapao/utils/datasets.py", line 665, in collate_fn
return torch.stack(img, 0), torch.cat(label, 0), path, shapes
RuntimeError: torch.cat(): Sizes of tensors must match except in dimension 0. Got 18 and 1 in dimension 1 (The offending index is 1) I think there is something wrong with labels but I don't know what it is. |
|
Thank you for your comment |
Thank you for your splendid work! But I have some questions about training my own data by using your model. For example, what should I do on my label files(.json)?
The text was updated successfully, but these errors were encountered: