Development Tools
In this blogpost I will cover the different tools I have used during the development process of this project.
General
The tool below is used in all implementations.
Github
This free hosting
website was used for version control. It uses the git open-source VCS (Version Controll System) enabling
a combination of both local and centralized version control. This allows for
easy and efficient management of progress in development.
AIDE Implementation
AIDE or the AI Diagnosis Engine includes the pre-trained AI model. This model allows
the diagnosis engine from the previous section to calculate the disease prediction
rankings. It also handles the image pre-processing of incoming requests. The
following components are involved in this process.
Anaconda Distribution
This tool is a python package manager and
provides the ability to easily manage, test and deploy development environments.
Pycharm
This IDE made by the
software company JetBrains, is used for Python development. It integrates
nicely with Git version control and provides robust code completion and
assistance.
Pykka
To implement this model in Python, a library called
Pykka is used. It was inspired by the Scala framework “Akka”, which is a
powerful implementation of the actor pattern. Pykka however, does not support
as many features as Akka. It is not meant to be a python port of this framework
but is capable enough for this implementation.
The actor model has a few basic rules in Pykka:
- An actor is an execution unit that executes concurrently with other actors.
- It does not share state with anybody else, but it can have its own state.
- It can only communicate with other actors by sending and receiving messages, if it has their address.
- When it receives a message, it may take actions like:
o Altering
its own state, e.g. so that it can react differently to a future message
o Sending
messages to other actors
o Starting
new actors
- It only processes one message at a time. Thus, a single actor does not give you any concurrency, and it does not need to use locks internally to protect its own state.
My implementation using this framework resulted
in two important classes, which I will describe below.
v Threading Actor
This implementation by the Pykka API is a class
that provides the basic actor capabilities. This actor is not the same as the
actor described in section 7.2. It refers to a class which, when initialized,
is executed by its own thread i.e. a Python threading.Thread. Moreover, when it
is asked for a response on a message as part of its implementation, it provides
a “Future” object which is a thin wrapper around a Python queue.Queue. This object
represents a value that will be available in the future. The value of this
“Future” is calculated as soon as its “get” method is called. My two classes
expanded on this base actor class to include the custom functionality necessary
for this project.
I
Aid Actor
The first custom actor class represents the
worker. Its goal is to process analysis requests parallel to other workers as
they execute on their own threads. To do this, it includes the AI
implementation explained in section 8.4. When it successfully identifies up to
three diseases that match the same plant type as the request indicates. The diseases
that are also part of the top 3 results in its analysis are returned encapsulated
in a Future.
II
Actor Manager
The second custom actor focuses on creating and
managing these aid actors. It distributes incoming requests for analysis among
its initialized aid actors. When one of its aid actors returns a request result,
it shapes these results into up to three classifications and places these on
the database. The log related to that request is then updated by this actor,
with references to up to three classifications. The user can compare these
classifications on the PlantCare app with their own observation and pick the
one that matches best as “chosen classification” for that log. However, if the
aid actor returns no values at all, then the log is updated to trigger the retry
system. The user can then choose to take a new picture and retry the analysis
process.
Firebase Admin / Pyrebase
This is the Firebase library for server-side
python applications. Just like the regular Firebase SDK described in 8.2.4,
this library provides abstraction in python to easily implement communication
with Firebase services. In this implementation, Firebase is used to send
results back to the database and check for new analysis requests.
Pyrebase was first used to implement this
functionality. However, during development this library was deprecated. It had
a flaw that would cause this implementation to stop listening for new analysis
request provided by the end-user after running for 30 minutes. This was caused
by the lack of a re-authentication system as the services required the user,
e.g. diagnosis engine, to send a refresh token after the 30-minute mark. Hence,
the switch was made to the new official Firebase Admin SDK provided by Google.
The new framework did not require many adjustments to be made and solved the
problem.
Pytorch
One of those packages is a popular open-source deep
learning platform for Python. one of the most popular among AI researchers/developers.
It allows for the development, training and testing of AI models using
dedicated graphical processing units (GPU) or central processing units (CPU). This
framework was used to train a pre-existing model well known for image
classification called AlexNet. This pre-trained model is then implemented into
a class that is used in the diagnosis engine implementation.
Android Implementation
In the
following paragraphs the tools used to develop the mobile app that is part of this solution, will be described in
further detail.
Android Studio
This is the
official IDE for Google’s Android operating system. It is built on JetBrains’ IntelliJ
IDEA and was designed specifically for Android development. Just like PyCharm
it integrates nicely with Git and provides robust code completion and
assistance. On top of that, it enables android App simulation for testing.
Firebase SDK
Firebase is the chosen database, storage, authentication and remote configuration tool for this project. In android development, this is made possible using the Firebase Software development kit (SDK) for android. This kit provides abstraction to easily implement communication with firebase services.
v FirebaseUI
FirebaseUI is an open source framework that
provides another layer of abstraction above standard firebase sdk to make certain
functionalities even easier to implement. For instance, an Android RecyclerView
with special FirebaseRecyclerAdapter that makes loading firebase data into a RecyclerView
much easier to implement.
v Authentication
On top of fast and reliable database services,
firebase offers authentication services. The authentication service can be used
to securely log-in and register users as soon as they want to use the app.
There are a few different forms of authentication, including email & password
-, federated identity provider -, phone number -, anonymous and custom
authentication. For this project, email and password authentication was chosen.
This also stores the personal information of the user in a secure way and satisfies
the security requirement.
v Storage
Even more
useful for my implementation is the “storage” service, firebase offers. This allows me to easily
upload and download files that are stored in the Google cloud storage system. The
syntax for this is almost identical to firebase database. In this project I use
this service to pass images between architectural components and store them.
Glide
This popular opensource android framework is a media
management and image loading utility that handles media decoding, memory and
disk caching, and resource pooling. It makes it easy to download and load
images into Android ImageViews and is used in this implementation for that
purpose.
Image Picker
This library makes it easy to select images
from the gallery and camera. It is used to pick images from local device
storage or take new images using the device camera, that need to be uploaded
and stored using firebase storage.
Comments
Post a Comment