Windows Pychram deployment Unet++ process

*Written for newcomers with absolutely zero basic knowledge ~ all the experts will laugh *

1 Download Unet++ package

Here I am using resources from the Bilibili course. The course name is "Essentials for Artificial Intelligence [Image Segmentation + Semantic Segmentation] Classic Project Practice. A computer expert will teach you how to do unet medical cell segmentation practice. Paramecia." They say it’s easy! 》
The special topic of the information is: "Practical Combat of Tang Yudi Unet Image Segmentation and Semantic Segmentation"
Information link: https://pan.baidu.com/s/1D7bvk2vco4vexCH92Iz8PQ ?pwd=860r
Extraction code: 860r
Course screenshots

2 Environment configuration

2.1 Virtual environment

The author uses a windows system, the compiler is pycharm, and runs in a virtual environment created by the author. The virtual environment python version is 3.9.16
Insert image description here

2.2 Installation of relevant libraries in pycharm

Hover the mouse and select Install under the library with the red wavy line. Repeat the operation until everything is installed.
Insert image description here

2.3 Preprocessing the data set

Modify preprocess_dsb2018, line 15, to the path for data preprocessing you want.
The preprocessing here is mainly to merge all the single masks in the \unet++\inputs\stage1_train\00ae65c1c6631ae6f2be1a449902976e6eb8483bf6b0740d00530220832c6d3e\masks path into one mask map,
Insert image description here

Insert image description here
Insert image description here

2.4 Run the debug process of train.py

After preprocessing, you can train and run the train.py file

3 Digression: Debug process record

3.1 AssertionError: Torch not compiled with CUDA enabled

This error is caused by not having CUDA. The author's environment is CPU, I have not downloaded CUDA, and there is no GPU. Therefore, it is necessary to replace the parts of the code that call CUDA and run them on the CPU.

1. First add this line of code to the head of the code (Be careful to distinguish between Chinese and English symbols)

 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Insert image description here

2. Then replace all .cuda() in the code with .to(device)
and you can run it in a cuda-free environment
Insert image description here

3.2 module ‘albumentations.augmentations.transforms’ has no attribute ‘Resize’

This is because the automatically installed albums library version is too high and incompatible. Just uninstall the albums you are installing in File——Settings——Python Interpreter, and then install version 1.1.0
Uninstall existing albumementations first
Install the albums library version 1.1.0
Insert image description here

3.3 Other error reports

AttributeError: module ‘albumentations.augmentations.transforms’ has no attribute ‘RandomRotate90’
AttributeError: module ‘albumentations.augmentations.transforms’ has no attribute ‘Flip’
AttributeError: module ‘albumentations.augmentations.transforms’ has no attribute ‘Resize’

Solution:
First

import albumentations as albu

Then replace the attributes reported in the error with albu.
Insert image description here

Guess you like

Origin blog.csdn.net/ArcGis_Niu/article/details/132218610