The final project of the course Programming in Python at NCU: An adversarial attacker supported in GUI
- Attack will results in errors if
use_cuda = False
is set in line 37, attacker.py. Therefore, if you don't have CUDA-supported GPU, then the Attack function won't work. See the below section "Environment" for more information. - Launching the application (python3 main.py) takes more than 5 seconds to load the modules and models
python3 main.py
python3 -m venv project
On unix-like OS (in bash or zsh)
source project/bin/activate
On Win10 (in powershell or cmd)
.\project\Scripts\activate.bat
CUDA must be installed and enabled (CUDA Toolkit 11.7 Downloads), otherwise attack() will result in errors
# In my Win10 environment I need to run the first command before the second to enable CUDA correctly
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113
pip install -r requirements.txt
https://keras.io/api/applications/resnet/#resnet50-function
https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator
https://www.tensorflow.org/api_docs/python/tf/keras/utils/load_img
https://www.tensorflow.org/api_docs/python/tf/keras/utils/img_to_array
https://www.tensorflow.org/api_docs/python/tf/keras/applications/resnet50/preprocess_input
Source of coffee.qss
Qt for Python Official Website
CUDA must be installed and enabled (CUDA Toolkit 11.7 Downloads), otherwise attack() will result in errors
-
Linux Distribution: Ubuntu-20.04
Kernel version: 5.10.102.1-microsoft-standard-WSL2 -
Windows 10 21H2 build 19044.1706
main.py is the entry point of gui application
It will import MainWindow() from ui_mainwindow.py and then display it.
The class Window is responsible for display image and buttons.
QImageReader.read() returns a QImage and then _set_image(QImage) will set the QLabel and display the QLabel image.
dialog.selectedFiles()[0] will be the absolute path of the selected file.
The selected image file will be opened or saved.
ui file is generated by pyside6-designer which is a GUI designer.
ui_mainwindow.py is generated by pyside6-uic which is a (*.ui) XML compiler.