Weekly Journal

Probably Last Blog Post

I just wanted to say that I added a data flow and an activity flow pdf on the main page. Now I mainly need to make this website look a little better.

Last Blog Post?

Well, it turns out using the Gmail API was harder than I anticipated. I think I'm missing something with the credentials; I'm not sure if I'll go back and mess with it anymore. I don't need another headache from it.

Otherwise, I thought my presentation on Wednesday went well. If nothing else, it's over. Now I just need to write some more comments. I think I'll focus on overall activity comments in Android Studio. Those would likely be the most useful.

Almost Done

The images are now being downloaded just by using a URL connection from Android Studio. Thanks to John for the suggestion! In addition to just displaying them once people click on the dog, I also got them to display in each entry of the listview (which was a pain to get the right layout for that).

In DisplayActivity I got the distances to show (so distance from the dog being added to each one in the list). I also got it to order the list based on distance.

There was some other stuff that popped up while I was working on it today, so I fixed that stuff. I should work on the form activity a bit more to make sure that certain fields are filled out.

I haven't looked at automatically sending emails much more, but I still don't think it will be too hard. Other than that it's mostly cleaning up some stuff. The other thing is automatically removing dogs after some condition is met. I should probably comment a fair bit more too for functions and activities. I think I did a decent job at commenting inside functions, although I'll probably still try to go through them and add more.

All that said, I feel like I could do a demo with my app right now.

Guess I Should Write Another One

Before I forget, I fixed the latitude and longitude earlier today. It turns out I didn't make the data type correctly in the MySQL table.

I can pull entries from the database just fine to get both all dogs entered by a user and possible matches for a new dog (although I still can't get PHP to send the image back). I could add the images to the database instead but then I'd need to make a new table, and if I want people to add dogs while they're home (to get a variance in location), then I'd have to do that soon. I can save pictures a user stores on the phone as well, but that only solves it in the MyDogsActivity, not in the DisplayActivity.

I have looked a bit as automatically sending an email if there might be a match (well the user clicks a button to send it (hopefully)). It doesn't seem like it will be hard at all thanks to Gmail's API.

I'm also thinking about how I'll automatically remove dogs.

I also started my presentation last night. I think I'm in a fine spot for Wednesday.

Finally, Database Progress

I finally have some database progress to report from this week. I can add dogs to the MySQL database (and it saves the actual image in a separate folder) and also remove dogs (although right now the unique id (its image path) has to be hardcoded. I looked at pulling entries from the database but that hasn't went quite as well so far. Well, it's the sending it back to my app and transferring it into a data structure. It's reading it fine from the database. One thing I need to hopefully quickly fix is the latitude and longitude being switched to ints instead of doubles when sending them to PHP.

I decided to use OkHttp to send the requests from Android Studio. I'm not 100% sure I'll be able to use it for receiving entries from PHP, or at least not without messing with making a thread wait.

Hopefully tomorrow, though, I can get that ironed out. If I can get it worked out in the activity I'm working in, then I just have to implement it into the other display activity.

Past that I want to work on a way to automatically remove dogs that have been in the database for too long (as sad as that may be). I also want to work on having the app email or send a notification to users when a possible match is found by another user.

App Progress

Well since my last blog post I have made a lot of progress with the app, both in planning and in programming. I have my 7 activities planned out. I am done with four. The rest still need database stuff, but two of the have a decent start.

I haven't really coded with databases, but I have done a lot of research. I might switch to Firebase's servers; it seems a lot easier to implement. Connecting with a MySQL server on Android seems like a bit of a pain.

Tomorrow I think I might work on my CNN for the first time in a while. Or actually try to implement Cloud Firestore in my app.

Location and Login

Yesterday I got location in order. Using Google's Fused Location Provider API. In my test activity, whenever a photo is taken from the gallery and tested, the latitude and longitude of the phone are (roughly) taken. Currently they are just toasted to the user. Later I'll be able to store and use them to show closer dogs.

Today I got Gmail login working. It keeps users logged in upon app restart. Maybe later I'll add a signout button. For now, though, it toasts your email when you open the main activity.

This weekend will be mostly dedicated to working with the database. Some progress shall be made.

CNN Running in App

Well it was a much bigger headache than I thought it would be (most of Friday), but my CNN is running in my Android app. I made a separate activity for "quick inferences," as a test/ also a way for people to quickly see what breed a certain dog is. Right now the photos come from the phone's gallery. I don't know whether or not I'll try to implement a camera activity.


I don't know how much I'll be able to work on it this week; I have a pretty busy week. Hopefully during spring break or before I'll be able to put a bit of time into it.

Next is definitely getting connection to a database. I think once I get used to it, then it won't be that bad.

Quick Update

Well I was gone for most of the last 4 days. Before that, though, I did make slight progress. The CNN is now in the correct format to be used by Tensorflow Lite (that took longer than I expected...).

This week/weekend I want to get that CNN into my app and also work with the database, hopefully populating lists in the app with info from it.

Fully Operation CNN

Well, I spent a decent amount of time this weekend getting a CNN working. Switching to the Stanford Dog dataset proved to be harder than I thought because of the its folder hierarchy. Anyways, it turned out to be very easy to work with thanks to a recent parameter to a certain function in Keras.

The CNN that I have trained now uses transfer learning. The Inception - v3 model is used as the base model. I added two Dense layers after it to "customize" it to the dogs dataset. To talk about the Inception - v3 model quickly, it is a huge pretrained model on massive amounts of images. It picks out features that the Dense layers I added pick apart a bit more and use them to identify dogs. From what I've read it goes a bit deeper into CNN theory as to why transfer learning works.

Anyways, my CNN right now got about 86% accuracy on the validation set on the last epoch I ran it on. I'm pretty happy with that, at least for now. Throughout this week, next, and for who knows how long I might make some adjustment before I go to bed or leave for a few hours and then let it retrain. I think I should be able to get closer to 95% accuracy. I could try a different base model too.

I think this coming week will be a rather dead week for me. For about three days at the end of the week I'll be at Madison. I might try to do some small things on the app throughout the next few days (or on this website with the formatting). Maybe I'll even mess with getting my CNN on the app. I'll try to get work done so not this weekend but the weekend after I can put a lot of work in, especially with the database if I don't get around to messing with it before that. (Some random late night could remedy that...)

I almost forgot this link that I wanted to share. It's a pretty cool example of what happens to an image as it goes through a CNN.

Number CNN

Convolutional NN

After messing around in Keras a bit, I think I might need to try transfer learning or really tweak the CNN more. I downloaded a different (bigger) dataset earlier, so that will help as well. Realistically, I think transfer learning might be the way to go to get great results.

This week will be another rough week with a senior math exam on Tuesday and then a French exam on Wednesday. After that I'm hoping to get all my work done before the weekend so I can just focus on this then. I'll try to get a CNN trained using transfer learning. I'll also try to get a database set up somewhere to really be able to move forward on the app.

Third Blog Post

Well it's really early Monday morning. I haven't made much programming progress since my last blog post, but there has been a bit in other areas.

One thing that I will work on soon is a form to get data (including the picture) from users. This will likely include things like location and color.

I believe I will be going with a CNN for my neural net. How exactly it'll look I'm not sure yet. I'll probably use Inception as some inspiration. I did see an example of someone that used Inception as a base of sorts and then trained two (I think) layers that went at the end of Inception to get very high accuracy for this problem. So it can definitely be done well!

This week (likely mostly Tuesday and Thursday, I'll work on that form and also on cleaning the data for a CNN, maybe even start training a smaller one.

Second Blog Post

CS philosophy was added this last Saturday. There's definitely some formatting work to do on this website but I don't think the basic stuff will be too bad.

There is a version of Tensorflow called Tensorflow Lite that I will be able to use to make inferences on my neural network on mobile devices. I can also make the neural net using Keras and then convert it, which is quite nice. Stanford has a dataset of around 20k dog images with their breed as the label, so hopefully that will be enough to make an adequate neural net. I'll start working on that soon in Python with Keras. I might have to use AWS or something similar for computing power depending on the training time.

I have a pretty good idea of what I want my app to look like (as of now). I'll keep seperate lists for dogs that have gone missing and for dogs that have been found. From the main screen, someone can view either list, or report a missing or found dog. I'm not entirely sure about the style of the lists yet, though. I suppose that wouldn't be the worst thing to change later on. I am anxious to get the scrolling lists of dogs working with information from a server. If that seems to be too far out I might fill it with data directly put into the project. The server connection area is an area I really don't know how to do yet.

So far my app has a main page with two buttons. Each opens a separate activity. These activities will have a scrolling feature that will show the current missing/found dogs. They currently are a different "style" so I want to figure out which I like more before really going for it (preferably with the help of a meeting). I also want to use actual data from a server to populate the lists, so that needs to get set up as well.

Some upcoming tasks include: Neural net in Python with Keras (getting started), getting server up and pulling data from it for app's use, work on existing Android activities to look better, make new one(s) that will display one dog when clicked on from list, and talk about/ decide on other narrowing methods after neural net.

As of now, if the server and getting data from it goes smoothly and quickly, I think I can make quick progress as long as I know what I want. The neural net could be constricted by time, so maybe AWS will come into play.

For the rest of the week I will focus on starting the neural net and just messing around in Android to get used to it again.

I'm expecting connecting to the server from the app, figuring out exactly how everything should work, and of course getting the neural net just right to be tough, at least for the imminent things.

First Blog Post

Well, here's my first entry. Over the past few days my website has gotten to the point of being up and running. While I'm not sure if I like the arrangement of things, that can be changed easily enough later. Bootstrap has been a great help with the website with templates for pages and parts of pages. (Also credit to John McGorey for the favicon.)

My CS philosphy will be done soon.

More research will be done tomorrow, along with a more in-depth blog post on that. So far, though, I think I will be using Android Studio. Hopefully I can incorporate some Python into the app to work with the neural network. I believe I will train the neural network in Spyder and then transport it to the app using the library pickle.

I think I will forego a login feature and instead have an email associated with each picture. Maybe entering in your email will bring up your lost dog(s).

Also this past Wednesday I got accepted to UW-Madison!