-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.txt
More file actions
124 lines (109 loc) · 4.18 KB
/
setup.txt
File metadata and controls
124 lines (109 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Set up môi trường Python trên Linux
apt update
# Với YOLO
apt install -y python3 python3-pip python3-venv
# Với Faster RCNN, RetinaNet, RTMDet
apt update
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9 python3.9-venv python3.9-dev -y
python3.9 -m venv venv
source venv/bin/activate
# Clone thư mục từ drive
apt install -y rclone
rclone config
n
drive
drive
Enter
Enter
Enter
1
Enter
Enter
n
y
Dang nhap
n
y
q
# Tải thư mục từ drive
mkdir -p /root/yolo_dataset
rclone copy "drive:/Đại học/Năm 2/images.zip" /root/yolo_dataset -P
rclone copy "drive:/Đại học/Năm 2/YOLO_labels.zip" /root/yolo_dataset -P
rclone copy "drive:/resnet50-0676ba61.pth" /root/COCO_dataset -P
# Unzip thư mục
apt install -y unzip
unzip __tenfile
# Cài các package để train model
source /root/venv/bin/activate
- Pytorch => Xem GPU để biết tải bản torch cho CUDA nào
pip uninstall torch torchvision torchaudio -y
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
- Ultralytics (YOLO)
pip install -U ultralytics
yolo checks
apt install -y libgl1
apt install -y libglib2.0-0
+ Chạy test
yolo detect val \
model=work_dirs/license_plate/yolov8/weights/best.pt \
data=datasets/license_plate.yaml \
imgsz=640 \
save_json=True
- MMDetection (Faster-RCNN, RetinaNet, RTMDet)
conda install pytorch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1 cudatoolkit=11.1 -c pytorch -c conda-forge
pip install mmengine==0.10.7
pip install mmcv==2.0.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
pip install "mmdet>=3.0.0"
+ Clone MMDetection về
git --version
* Nếu không có git trên server
sudo apt update
sudo apt install git -y
+ Copy file configs
cp configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py \ configs/license_plate
cp configs/retinanet/retinanet_r50_fpn_1x_coco.py \ configs/license_plate
cp configs/rtmdet/rtmdet_s_8xb32-300e_coco.py \ configs/license_plate
+ Train từ đầu
python tools/train.py \ configs/license_plate/faster_rcnn_r50_1x_coco.py \ --work-dir work_dirs/license_plate/faster_rcnn
python tools/train.py \ configs/license_plate/retinanet_r50_fpn_1x_coco.py
python tools/train.py \ configs/license_plate/rtmdet_s_8xb32-300e_coco.py
+ Train từ checkpoint nếu bị crash server
python tools/train.py \ configs/license_plate/faster_rcnn_r50_1x_coco.py --resume
python tools/train.py \ configs/license_plate/retinanet_r50_fpn_1x_coco.py --resume
python tools/train.py \ configs/license_plate/rtmdet_s_8xb32-300e_coco.py --resume
+ Chạy test
python tools/test.py \
configs/license_plate/faster_rcnn_r50_fpn_bs32_20e.py \
work_dirs/faster_rcnn_r50_fpn_bs32_20e/best_bbox_mAP.pth \
--out work_dirs/faster_rcnn_r50_fpn_bs32_20e/preds.json
# Note: Cấu trúc thư mục khi train bằng MMDetection
mmdet_project/
│
├── mmdetection/
├── configs/
│ ├── _base_/
│ ├── faster_rcnn/
│ ├── retinanet/
│ ├── rtmdet/
│ └── license_plate/
│ ├── faster_rcnn_r50_fpn_bs32_20e.py <- File config của mình
│ ├── retinanet_r50_fpn_bs32_20e.py <- File config của mình
│ └── rtmdet_s_bs32_20e.py <- File config của mình
│
├── data/
│ └── license_plate/
│ ├── train/
│ │ ├── 0001.jpg
│ │ └── ...
│ ├── val/
│ │ ├── 1001.jpg
│ │ └── ...
│ └── annotations/
│ ├── train.json
│ └── val.json
│
└── work_dirs/
└── faster_rcnn_bs32_20e/