- keras: Version 2.8.0
- numpy: Version 1.19.5
- pillow: Version 8.4.0
- python: Version 3.8.10
- matplotlib: Version 3.5.1
- scikit-learn: Version 1.0.2
- tensorflow-gpu: Version 2.4.0 or
- tensorflow: Version 2.4.0
- opencv-python: Version 4.5.4.58
In this script the camera is calibrated and the data set for image analysis is created.
In the script tool classification the neural network is trained to classify the tool. In the end, the trained model is obtained and the tools can be classified.
In the Wear measurement script, the recorded data set can be extended for training. Further the network can be trained. At the end of the training, the pre-trained model for Semantic Segmentation is obtained. After that the wear of the parts can be measured.
For comfortable work install ConEmu https://conemu.github.io/ for Powershell. You can two tabs in one with hotkeys open
- Strg + Shift + e or
- Strg + Shift + o
- Create a virtual environment
python -m venv env_wear_measurement
- Activate the virtual environment
.\env_fabian-gpu\Scripts\activate
- Install python packages
pip install keras==2.8.0
pip install numpy==1.19.5
pip install pillow==8.4.0
pip install matplotlib==3.5.1
pip install scikit-learn==1.0.2
pip install tensorflow-gpu==2.4.0
pip install opencv-python==4.5.4.58
- Clone the project from https://github.com/iusav/wear_measurement
git clone https://github.com/iusav/wear_measurement.git
If you want to clone a specific branch run, e.g.
git clone https://github.com/iusav/wear_measurement.git -b fabian_kohnle
- Install VS Code for development
- Open the "wear_measurement" project on VS Code
- Access camera
- Crop the window to 960x960 pixels
- When starting the program, the window with the camera section opens
- Place the "Calibration Target" of the Dino-Lite microscope on the wear surface.
- Take a picture with the "k" key
- Mark distance (keep mouse button pressed)
- Output the number of pixels between the distance
- To close all windows press "Esc" for at least 1 sec.
$ python calibration.py
$ python camera_wear_measurement.py
- Enter value from calibration.py in
calibration= ...
. - Load stored (trained) model
model = tf.keras.models.load_model('Name')
- Image section opens
- Capture image with "k
- Evaluation appears (wear surface is displayed in the console)
- When closing the evaluation a new window appears where it is possible to measure the wear mark width manually, if wanted
- Closing the window leads to a new start of the measurements (end of the wear measurement by holding down the Esc key)
$ python camera_tool_classification.py
- Run program further (Training)
$ python tool_class_training.py
- Enter the file path of the image (Enter Filepath:)
- Load saved model
loaded_model = tf.keras.models.load_model('Modellname')
- Prediction evaluation (Plot)
$ python tool_class_evaluation.py
Wendeschneidplatte | Schaftfräser | Wendeschneidplatte |
---|---|---|
- Defining the U-Net model
- Loading the images from the folder where the original images are located
- Data augmentation
- U-Net Modell loading
- Modell Training
$ python segmentation_training.py
- Saving results of the model
model.save('Name')
- Evaluation of the training process (Accuracy/Loss)
- Calculation of IoU score
- Loading a saved model
model = tf.keras.models.load_model('Name')
$ python segmentation_evaluation.py
- Loading image to be evaluated
test_img_other = cv2.imread("C:/.../.../Verschleissbild")
- If desired: A manually created mask can be loaded to compare the prediction with the real wear surface (IoU score).
- Plotting of the results
Input --> Output |
---|
--- |
--- |