-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JonatanRasmussen/pytest
added unit tests and coverage reports to project
- Loading branch information
Showing
63 changed files
with
141 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[run] | ||
omit = | ||
*__init__* | ||
*/tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Python application | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Test with pytest | ||
run: | | ||
coverage run -m pytest tests/ | ||
coverage html --title="DTU 02476 Group 100 Project Coverage Report" | ||
- name: Upload pytest test results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-report | ||
path: htmlcov/ | ||
# Use always() to always run this step to publish test results when there are test failures | ||
if: ${{ always() }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from project_winegrape_src_files.models.model import MyNeuralNet | ||
from project_winegrape_src_files.models.model import ImageClassifier | ||
from project_winegrape_src_files.predict_model import predict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
reproducibility: | ||
seed: 123 | ||
|
||
data: | ||
dir: "tests/test_data/raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset" | ||
transform_level: "light" | ||
batch_size: 32 | ||
val_split: 0.2 | ||
|
||
model: | ||
model_name: "efficientnet_b0" # or resnetv2_50t | ||
num_classes: 5 | ||
drop_rate: 0.3 | ||
pretrained: true | ||
|
||
optimization: | ||
lr_pretrained: 1e-5 | ||
lr_final: 1e-4 | ||
optimizer: "AdamW" | ||
criterion: "cross_entropy" | ||
|
||
training: | ||
max_epochs: 40 | ||
|
||
logging: | ||
log_every_n_steps: 40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" | |
[project] | ||
name = "project_winegrape_src_files" | ||
version = "0.0.1" | ||
description = "Your project description" | ||
description = "" | ||
authors = [ | ||
{ name = "Your Name", email = "[email protected]" }, | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
torch >= 2.1.0 | ||
timm >= 0.9.12 | ||
pytorch-lightning >= 2.1.3 | ||
torchvision >= 0.16.0 | ||
torchmetrics >= 1.2.1 | ||
numpy >= 1.26.0 | ||
opendatasets >= 0.1.22 | ||
hydra-core >= 1.3.2 | ||
omegaconf >= 2.3.0 | ||
click==8.1.7 | ||
coverage==7.4.0 | ||
dvc==3.39.0 | ||
dvc-gdrive==3.0.1 | ||
hydra-core==1.3.2 | ||
kaggle==1.6.2 | ||
Markdown==3.5.2 | ||
numpy==1.26.3 | ||
omegaconf==2.3.0 | ||
opendatasets==0.1.22 | ||
pytest==7.4.4 | ||
pytorch_lightning==2.1.3 | ||
timm==0.9.12 | ||
torch==2.1.2 | ||
torchmetrics==1.3.0 | ||
torchvision==0.16.2 |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from hydra import initialize, compose | ||
import os | ||
|
||
def test_config() -> None: | ||
with initialize(version_base=None, config_path="../project_winegrape_src_files/conf"): | ||
test_cfg = compose(config_name="test_config") | ||
# assert top level keys | ||
assert "reproducibility" in test_cfg.keys() | ||
assert "data" in test_cfg.keys() | ||
assert "model" in test_cfg.keys() | ||
assert "optimization" in test_cfg.keys() | ||
assert "training" in test_cfg.keys() | ||
assert "logging" in test_cfg.keys() | ||
# assert data exists | ||
assert os.path.exists(os.path.dirname(test_cfg.data.dir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from project_winegrape_src_files.data.data import DataModule | ||
from hydra import initialize, compose | ||
|
||
def test_data(): | ||
with initialize(version_base=None, config_path="../project_winegrape_src_files/conf"): | ||
test_cfg = compose(config_name="test_config") | ||
data_module = DataModule( | ||
data_dir=test_cfg.data.dir, | ||
transform_level=test_cfg.data.transform_level, | ||
batch_size=test_cfg.data.batch_size, | ||
val_split=test_cfg.data.val_split, | ||
) | ||
data_module.setup() | ||
training_dataset = data_module.train_dataloader() | ||
val_dataset = data_module.val_dataloader() | ||
test_dataset = data_module.test_dataloader() | ||
assert len(training_dataset) == 2 | ||
assert len(val_dataset) == 1 | ||
assert len(test_dataset) == 1 |
Binary file added
BIN
+80.5 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+118 KB
...aw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (10).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+292 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+350 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+293 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+270 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+137 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+228 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (7).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+162 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (8).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+289 KB
...raw/grapevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ak/Ak (9).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+264 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+147 KB
...eaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (10).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+151 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+301 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+121 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+323 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+131 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+271 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (7).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+154 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (8).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+302 KB
...leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Ala_Idris/Ala_Idris (9).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+143 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+214 KB
...ne-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (10).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+262 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+142 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+293 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+202 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (5).png
Oops, something went wrong.
Binary file added
BIN
+171 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (6).png
Oops, something went wrong.
Binary file added
BIN
+199 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (7).png
Oops, something went wrong.
Binary file added
BIN
+260 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (8).png
Oops, something went wrong.
Binary file added
BIN
+254 KB
...ine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Buzgulu/Buzgulu (9).png
Oops, something went wrong.
Binary file added
BIN
+232 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (1).png
Oops, something went wrong.
Binary file added
BIN
+137 KB
...vine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (10).png
Oops, something went wrong.
Binary file added
BIN
+139 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (2).png
Oops, something went wrong.
Binary file added
BIN
+242 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (3).png
Oops, something went wrong.
Binary file added
BIN
+217 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (4).png
Oops, something went wrong.
Binary file added
BIN
+316 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (5).png
Oops, something went wrong.
Binary file added
BIN
+186 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (6).png
Oops, something went wrong.
Binary file added
BIN
+252 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (7).png
Oops, something went wrong.
Binary file added
BIN
+217 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (8).png
Oops, something went wrong.
Binary file added
BIN
+317 KB
...evine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Dimnit/Dimnit (9).png
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...ataset/Grapevine_Leaves_Image_Dataset/Grapevine_Leaves_Image_Dataset_Citation_Request.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
DATASET: https://www.muratkoklu.com/datasets/ | ||
|
||
KOKLU Murat (a), UNLERSEN M. Fahri (b), OZKAN Ilker Ali (a), ASLAN M. Fatih(c), SABANCI Kadir (c) | ||
|
||
(a) Department of Computer Engineering, Selcuk University, Turkey, Konya, Turkey | ||
(b) Department of Electrical and Electronics Engineering, Necmettin Erbakan University, Konya, Turkey | ||
(c) Department of Electrical-Electronic Engineering, Karamanoglu Mehmetbey University, Karaman, Turkey | ||
|
||
Citation Request : | ||
Koklu, M., Unlersen, M. F., Ozkan, I. A., Aslan, M. F., & Sabanci, K. (2022). A CNN-SVM study based on selected deep features for grapevine leaves classification. Measurement, 188, 110425. Doi:https://doi.org/10.1016/j.measurement.2021.110425 | ||
|
||
Link: https://doi.org/10.1016/j.measurement.2021.110425 | ||
|
||
DATASET: https://www.muratkoklu.com/datasets/ | ||
|
||
Highlights | ||
• Classification of five classes of grapevine leaves by MobileNetv2 CNN Model. | ||
• Classification of features using SVMs with different kernel functions. | ||
• Implementing a feature selection algorithm for high classification percentage. | ||
• Classification with highest accuracy using CNN-SVM Cubic model. | ||
|
||
Abstract: The main product of grapevines is grapes that are consumed fresh or processed. In addition, grapevine leaves are harvested once a year as a by-product. The species of grapevine leaves are important in terms of price and taste. In this study, deep learning-based classification is conducted by using images of grapevine leaves. For this purpose, images of 500 vine leaves belonging to 5 species were taken with a special self-illuminating system. Later, this number was increased to 2500 with data augmentation methods. The classification was conducted with a state-of-art CNN model fine-tuned MobileNetv2. As the second approach, features were extracted from pre-trained MobileNetv2′s Logits layer and classification was made using various SVM kernels. As the third approach, 1000 features extracted from MobileNetv2′s Logits layer were selected by the Chi-Squares method and reduced to 250. Then, classification was made with various SVM kernels using the selected features. The most successful method was obtained by extracting features from the Logits layer and reducing the feature with the Chi-Squares method. The most successful SVM kernel was Cubic. The classification success of the system has been determined as 97.60%. It was observed that feature selection increased the classification success although the number of features used in classification decreased. | ||
|
||
Keywords: Deep learningTransfer learningSVMGrapevine leavesLeaf identification |
Binary file added
BIN
+159 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (1).png
Oops, something went wrong.
Binary file added
BIN
+381 KB
...pevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (10).png
Oops, something went wrong.
Binary file added
BIN
+233 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (2).png
Oops, something went wrong.
Binary file added
BIN
+177 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (3).png
Oops, something went wrong.
Binary file added
BIN
+125 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (4).png
Oops, something went wrong.
Binary file added
BIN
+175 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (5).png
Oops, something went wrong.
Binary file added
BIN
+278 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (6).png
Oops, something went wrong.
Binary file added
BIN
+175 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (7).png
Oops, something went wrong.
Binary file added
BIN
+131 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (8).png
Oops, something went wrong.
Binary file added
BIN
+269 KB
...apevine-leaves-image-dataset/Grapevine_Leaves_Image_Dataset/Nazli/Nazli (9).png
Oops, something went wrong.