Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 244 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@

# Created by https://www.toptal.com/developers/gitignore/api/python,vscode,database,django
# Edit at https://www.toptal.com/developers/gitignore?templates=python,vscode,database,django

.vscode
### Database ###
*.accdb
*.db
*.dbf
*.mdb
*.pdb
*.sqlite3

### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/

### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log

# Translations
*.mo

# Django stuff:

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
# .env
.env/
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# operating system-related files
*.DS_Store #file properties cache/storage on macOS
Thumbs.db #thumbnail cache on Windows

# profiling data
.prof


### Python ###
# Byte-compiled / optimized / DLL files

# C extensions

# Distribution / packaging

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.

# Installer logs

# Unit test / coverage reports

# Translations

# Django stuff:

# Flask stuff:

# Scrapy stuff:

# Sphinx documentation

# PyBuilder

# Jupyter Notebook

# IPython

# pyenv

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.

# poetry

# PEP 582; used by e.g. github.com/David-OConnor/pyflow

# Celery stuff

# SageMath parsed files

# Environments
# .env

# Spyder project settings

# Rope project settings

# mkdocs documentation

# mypy

# Pyre type checker

# pytype static type analyzer

# operating system-related files

# profiling data


### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/python,vscode,database,django
5 changes: 3 additions & 2 deletions active_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import matplotlib.pyplot as plt
from modAL.models import ActiveLearner
from keras.wrappers.scikit_learn import KerasClassifier

from query import Query


Expand Down Expand Up @@ -30,8 +31,8 @@ def loop(
y_test,
X_unlabeled,
accuracy_goal,
) :
):

# accuracy of model with initialize images
model_accuracy = self.score(X_test, y_test, verbose=0)
print("\nAccuracy after query {n}: {acc:0.4f}".format(n=0, acc=model_accuracy))
Expand Down
8 changes: 4 additions & 4 deletions especificacoes.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"training_path":"C:\\Users\\jpmrs\\OneDrive\\Desktop\\UTAD\\Projeto de licenciatura\\Mucosa\\Datasets\\train",
"testing_path":"C:\\Users\\jpmrs\\OneDrive\\Desktop\\UTAD\\Projeto de licenciatura\\Mucosa\\Datasets\\test_set_complete",
"validation_path":"C:\\Users\\jpmrs\\OneDrive\\Desktop\\UTAD\\Projeto de licenciatura\\Mucosa\\Datasets\\validation",
"unlabeled_path":"C:\\Users\\jpmrs\\OneDrive\\Desktop\\UTAD\\Projeto de licenciatura\\Mucosa\\Datasets\\unlabeled",
"training_path":"Datasets/train",
"testing_path":"Datasets/test_set_complete",
"validation_path":"Datasets/validation",
"unlabeled_path":"Datasets/unlabeled",
"build_fn":"create_cnn",
"query_strategy":"RandomQuery",
"accuracy":0.90,
Expand Down
12 changes: 8 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from query import RandomSampling,UncertaintySampling, ClusterBasedSampling,RepresentativeSampling,Uncertainty_With_Clustering_Sampling,Representative_With_Clustering_Sampling,Highest_Entropy__Clustering_Sampling,Uncertainty_With_Representative_sampling,Highest_Entropy__Uncertainty_Sampling
from query import (
ClusterBasedSampling,
)
from keras.preprocessing.image import ImageDataGenerator
from active_learner import ActiveLearner
import os
Expand All @@ -13,6 +15,7 @@

input_shape = (128, 128, 3)


def create_cnn():
model = models.Sequential()
model.add(layers.Conv2D(32, (4, 4), activation="relu", input_shape=input_shape))
Expand All @@ -31,15 +34,16 @@ def create_cnn():
)
return model

os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"

os.environ["TF_FORCE_GPU_A_LLOW_GROWTH"] = "true"

# read file
with open("especificacoes.json", "r") as myfile:
data = myfile.read()
# parse file
obj = json.loads(data)

datagen = ImageDataGenerator(rescale=1.0 / 255)
datagen = ImageDataGenerator(rescale=1.0 / 255)
train_generator = datagen.flow_from_directory(
str(obj["training_path"]),
target_size=(128, 128),
Expand Down Expand Up @@ -76,7 +80,7 @@ def create_cnn():

learner = ActiveLearner(
locals()[obj["build_fn"]],
Highest_Entropy__Uncertainty_Sampling(X_unlabeled, int(obj["n_instances"])),
ClusterBasedSampling(int(obj["n_instances"])),
X_initial,
y_initial,
verbose=0,
Expand Down
Loading