Giter Club home page Giter Club logo

oneteacher's Introduction

OneTeacher

Official implementation of "Towards End-to-end Semi-supervised Learning for One-stage Object Detection". OneTeacher is a semi-supervised framework for YOLOV5, which is equiped with two novel designs, namely Multi-view Pseudo-label Refinement and Decoupled Semi-supervised Optimization.

Updates

  • (2023/1/29) Release our project.

Data Preparation

  1. Prepare the datasets of COCO and VOC, please refer to YOLOv5

After that, the file structure should look like:

   |-- OneTeacher
   |-- datasets
       |-- coco
             |-- images
                  |-- train2017
                  |-- val2017
                  |-- test2017
             |-- labels
             |-- annotations
                  |-- instances_train2017.json
                  |-- instances_val2017.json
  1. Generate semi-supervised data split.
python active_sampling/generate_random_supervised_seed_yolo.py  --dataset_name 'coco_2017_train'  --random_seeds 0,1,2,3,4,5,6,7,8,9  --random_file  ./data_processing/COCO_supervision.txt   --random_percent 10.0  --output_file ./dataseed/COCO_supervision_10.json

Training and Evaluation

Semi-supervised Learning on COCO 10%

bash script/coco_semi_script.sh 32 2 0,1

Semi-supervised Learning on VOC 25%

bash script/voc_semi_script.sh 32 2 0,1

Fully-supervised Learning on COCO 10%

bash script/coco_fully_script.sh 32 2 0,1

Fully-supervised Learning on VOC 25%

bash script/voc_fully_script.sh 32 2 0,1

oneteacher's People

Contributors

luogen1996 avatar

Stargazers

 avatar  avatar  avatar Research-PHD avatar  avatar Ray avatar  avatar jdlkd avatar  avatar 2049 avatar Zheng-Yuan Xie avatar  avatar  avatar  avatar Wenfei Zhu avatar chengshunli  avatar  avatar xinzhichao avatar  avatar  avatar  avatar  avatar  avatar Tim avatar  avatar  avatar  avatar  avatar  avatar 魔鬼面具 avatar  avatar MaKe avatar river_cold avatar Cj avatar  avatar HaroldHuanrongLIU avatar DS.Xu avatar swan avatar  avatar 爱可可-爱生活 avatar Xiyang Liu avatar  avatar Ren Tianhe avatar Mr.Felix avatar  avatar n-zyp avatar  avatar  avatar Jing He avatar  avatar Shane Zhao avatar Zhuojun Sun CV Student avatar CCODING avatar zhouchanggeng avatar  avatar  avatar  avatar An-zhi WANG avatar Honglin LI avatar  avatar HunterJoan Lim avatar  avatar rotorliu avatar Psyduck avatar Liu Tianying avatar Jie Hu avatar serser avatar  avatar  avatar Range King avatar  avatar alpha avatar Byronnar avatar David avatar  avatar Chen Liang avatar Yaya Shi avatar

Watchers

 avatar

oneteacher's Issues

do you know how to solve this issue "NameError: name '_SPLITS_COCO5_FORMAT' is not defined" ?

when i execution this command ,

"python data_processing/generate_random_supervised_seed_yolo.py --dataset_name 'coco_2017_train' --random_seeds 0,1,2,3,4,5,6,7,8,9 --random_file ./data_processing/COCO_supervision.txt --random_percent 10.0 --output_file ./dataseed/COCO_supervision_10.json"

this error was occured .

"Traceback (most recent call last):
File "data_processing/generate_random_supervised_seed_yolo.py", line 7, in
from builtin import *
File "/home/ssod/OneTeacher/data_processing/builtin.py", line 175, in
register_coco5(_root)
File "/home/ssod/OneTeacher/data_processing/builtin.py", line 115, in register_coco5
for _, splits_per_dataset in _SPLITS_COCO5_FORMAT.items():
NameError: name '_SPLITS_COCO5_FORMAT' is not defined"

please help me.

About train_semi.py

When i excute the script, it met the problem(it appeared epoch 12):
Traceback (most recent call last): File "train_20.py", line 920, in <module> main(opt) File "train_20.py", line 818, in main train(opt.hyp, opt, device, callbacks) File "train_20.py", line 511, in train out, train_out,pseudo_class_one_hot =model_teacher(unlabel_imgs_weak_aug,augment=True) File "/home/yy/miniconda3/envs/general/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/yy/log/4.semi-supervised/OneTeacher-main/models/yolo.py", line 523, in forward return self.forward_augment(x) # augmented inference, None File "/home/yy/log/4.semi-supervised/OneTeacher-main/models/yolo.py", line 533, in forward_augment xi = scale_img(x.flip(fi) if fi else x, si, gs=int(self.stride.max())) File "/home/yy/log/4.semi-supervised/OneTeacher-main/utils/torch_utils.py", line 300, in scale_img s = (int(h * ratio), int(w * ratio)) # new size TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'@ @luogen1996

关于论文中的一个疑问

屏幕截图 2023-10-14 132620
论文中这张图表示了在使用ImageNet pre-training后的one-teacher和其它方法结果的比较,但是论文中前面写道one-teacher使用的是yolov5-s作为base model。yolo的backbone结构和resnent差距挺大的,如果我想复现这部分实验结果,请问我该如何使用ImageNet的预训练权重来初始化yolov5-s?

About non_max_suppression_pseudo_decouple_multi_view

if isinstance(out,list):
 
pseudo_boxes_reg, pseudo_boxes_cls = non_max_suppression_pseudo_decouple_multi_view(out, hyp[ 'bbox_threshold'], hyp['cls_threshold'], multi_label=True ,agnostic=single_cls, )

else:
 
pseudo_boxes_reg,pseudo_boxes_cls = non_max_suppression_pseudo_decouple(out, hyp['bbox_threshold'],hyp['cls_threshold'], multi_label=True, agnostic=single_cls )

if isinstance(out,list):

When I run code, it always run at non_max_suppression_pseudo_decouple. How type of model, how type config can output a list and run non_max_suppression_pseudo_decouple_multi_view?

train_semi error about student model !!!!!

after resolving all problems about training my custom dataset with One teacher when I launch the training, I got this error:

 Epoch   gpu_mem       box       obj       cls       mls  semi_obj  semi_cls  semi_mls    labelssemi_labels
 0/299     2.68G    0.1051   0.09514   0.01167   0.09257         0         0         0       104         0:  22%|███████▊                            | 3000/13860 [02:58<10:45, 16.81it/s]

Traceback (most recent call last):
File "/app/train_semi.py", line 931, in
main(opt)
File "/app/train_semi.py", line 829, in main
train(opt.hyp, opt, device, callbacks)
File "/app/train_semi.py", line 510, in train
_update_teacher_model(model if ema is None else ema.ema, model_teacher, word_size=WORLD_SIZE, keep_rate=0.)
File "/opt/conda/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/app/utils/torch_utils.py", line 48, in _update_teacher_model
raise Exception("{} is not found in student model".format(key))
Exception: model.0.conv.conv.weight is not found in student model

How could I resolve it ?

About data_processing/generate_random_supervised_seed_yolo.py

  1. 发生异常: NameError name '_SPLITS_COCO5_FORMAT' is not defined File "/home/cv/yj/5.semi-object/OneTeacher-main/data_processing/builtin.py", line 103, in register_coco5 for _, splits_per_dataset in _SPLITS_COCO5_FORMAT.items(): File "/home/cv/yj/5.semi-object/OneTeacher-main/data_processing/builtin.py", line 160, in <module> register_coco5(_root) File "/home/cv/yj/5.semi-object/OneTeacher-main/data_processing/generate_random_supervised_seed_yolo.py", line 7, in <module> from builtin import * NameError: name '_SPLITS_COCO5_FORMAT' is not defined
  2. generate_random_supervised_seed_yolo.py: error: unrecognized arguments: --output_file, how to generate the COCO_supervision_10.json, what is the form of COCO_supervision_10.json?
  3. where is the active_sampling directory, data_processing directory denotes active_sampling directory?
  4. If i want to use own datasets, how can i use generate_random_supervised_seed_yolo.py? it exists some problems Attribute 'thing_classes' in the metadata of 'coco_2017_train' cannot be set to a different value! ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] != ['graminearum', 'pseudograminearum', 'moniliforme', 'glycines', 'gloeosporioides', 'clavispora', 'anthracnose'] File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/catalog.py", line 148, in __setattr__ assert oldval == val, ( File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/datasets/coco.py", line 80, in load_coco_json meta.thing_classes = thing_classes File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/datasets/coco.py", line 500, in <lambda> DatasetCatalog.register(name, lambda: load_coco_json(json_file, image_root, name)) File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/catalog.py", line 58, in get return f() File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/build.py", line 241, in <listcomp> dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in names] File "/home/cv/yj/5.semi-object/detectron2/detectron2/data/build.py", line 241, in get_detection_dataset_dicts dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in names] File "/home/cv/yj/5.semi-object/OneTeacher-main/data_processing/generate_random_supervised_seed_yolo.py", line 11, in generate dataset_dicts = get_detection_dataset_dicts( File "/home/cv/yj/5.semi-object/OneTeacher-main/data_processing/generate_random_supervised_seed_yolo.py", line 55, in <module> generate( AssertionError: Attribute 'thing_classes' in the metadata of 'coco_2017_train' cannot be set to a different value! ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] != ['grami', 'pseudogrami', 'monili', 'glyci', 'gloeos', 'clavis', 'anth']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.