当前位置:网站首页>Actual combat of industrial defect detection project (IV) -- ceramic defect detection based on hrnet
Actual combat of industrial defect detection project (IV) -- ceramic defect detection based on hrnet
2022-04-23 02:41:00 【Summer melts the season】
be based on HRNet Ceramic defect detection
1. principle :
Refer to the articles of the big guys
HRNet: HRNet principle .
2. Data set preparation and code
Data download link :https://aistudio.baidu.com/aistudio/datasetdetail/32615
Code download link :https://gitee.com/wxyfmq123456/HRNet-Image-Classification?_from=gitee_search
3. Binarization of original graph
Here, the data set has provided a binary image png, We need to use png Image training . Because the original image is particularly inconspicuous .

in total 6 Categories .
4. Parameter configuration
(1) Data storage location :

(2) Data storage method :

Each folder represents a type , All the pictures inside are binary pictures (.png), Original picture (.jpg) It can be deleted or backed up elsewhere .
(3) Modify the code

open cls_hrnet.py, modify
self.classifier = nn.Linear(2048, 1000)
by
self.classifier = nn.Linear(2048, 6)
That is, the following parameters are Number of categories .
(4) Select profile

Let's pick the first one , namely :
cls_hrnet_w18_sgd_lr5e-2_wd1e-4_bs32_x100.yaml
Modify the parameters inside , take
DATASET:
DATASET: 'imagenet'
DATA_FORMAT: 'jpg'
ROOT: 'data/imagenet/'
TEST_SET: 'val'
TRAIN_SET: 'train'
It is amended as follows
DATASET:
DATASET: 'data'
DATA_FORMAT: 'png'
ROOT: 'imagenet'
TEST_SET: 'val'
TRAIN_SET: 'train'
The reason is that the path we set is different from the code .
The other parameters , Like the number of iterations epoch,bath_size etc. , You can adjust your parameters .
(5) stay train.py Add the following code to
train_dataset = datasets.ImageFolder(
traindir,
transforms.Compose([
transforms.RandomResizedCrop(config.MODEL.IMAGE_SIZE[0]),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
normalize,
])
)
# The following is the added code , The above lines are the original code
#print(train_dataset.classes) # The category is determined according to the name of the sub folder
with open("class.txt","w") as f1:
for classname in train_dataset.classes:
f1.write(classname + "\n")
#print(train_dataset.class_to_idx) # Define indexes for these categories in order as 0,1...
with open("classToIndex.txt", "w") as f2:
for key, value in train_dataset.class_to_idx.items():
f2.write(str(key) + " " + str(value) + '\n')
#print(train_dataset.imgs) # Returns the path and category of pictures from all folders
You can keep the corresponding index.
5. Training
python tools/train.py --cfg experiments/cls_hrnet_w18_sgd_lr5e-2_wd1e-4_bs32_x100.yaml
After training output In the folder
Weight offset file :final_state.pth.tar
6. test
Pictures of the test , Note that the verification set is still read here vaild, So to test a picture , We can turn the picture of the verification set into a , Put in, for example, a place called test In the folder of , The path is shown in the figure :

stay HRNet-Image-Classification-master\lib\core\function.py Inside def validate function , add to
print('class:{}'.format(output.argmax(1)))
Print the identified category index.
function :
python tools/vaild.py --cfg experiments/cls_hrnet_w18_sgd_lr5e-2_wd1e-4_bs32_x100.yaml
The of the category will be printed index.
版权声明
本文为[Summer melts the season]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220748368408.html
边栏推荐
- Those years can not do math problems, using pyhon only takes 1 minute?
- Modify the content of MySQL + PHP drop-down box
- JVM runtime data area (I)
- JVM class loader
- Efficient music format conversion tool Music Converter Pro
- Implementation of distributed scenario business operation log (based on redis lightweight)
- How big the program development of single chip microcomputer project can be, it represents your level of knocking code
- Hack the box optimum
- MySQL复杂查询使用临时表/with as(类似表变量)
- First day of rhcsa
猜你喜欢

Deploying sbert model based on torchserve < semantic similarity task >

Servlet template engine usage example
![[wechat applet] set the bottom menu (tabbar) for the applet](/img/e2/98711dfb1350599cbdbdf13508b84f.png)
[wechat applet] set the bottom menu (tabbar) for the applet

手写内存池以及原理代码分析【C语言】

010_ StringRedisTemplate

基于Torchserve部署SBERT模型<语义相似度任务>

定了,今日起,本号粉丝可免费参与网易数据分析培训营!

16、 Anomaly detection

Flink stream processing engine system learning (I)
![[XJTU computer network security and management] Lecture 2 password technology](/img/b0/263e8dcbfeb2ce9f504a9c8eb76b07.png)
[XJTU computer network security and management] Lecture 2 password technology
随机推荐
Rhcsa day 4 operation
JDBC JDBC
grain rain
[unity3d] rolling barrage effect in live broadcasting room
Explain JS prototype and prototype chain in detail
解决 注册谷歌邮箱 gmail 手机号无法用于验证
Niuke hand speed monthly race 48 C (I can't understand the difference. It belongs to yes)
能做多大的单片机项目程序开发,就代表了你的敲代码的水平
JZ76 删除链表中重复的结点
Halo open source project learning (I): project launch
RT_Thread自问自答
How to recognize products from the perspective of Dialectics
LeetCode 1450 - 1453
Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL
WordPress calls the specified page content. 2 get_ children()
Preliminary understanding of stack and queue
C language 171 Number of recent palindromes
Interpretation of the future development of smart agriculture
JVM运行时数据区(一)
16、 Anomaly detection