Oliver’s Status Report – 26 Mar 2022

Indeed, as I’ve talked about in the team status report, we are now entering the phase of the project where the fun truly starts, and the product begins to take shape. This week, I kicked off the integration process between the front-end and back-end, ironing out kinks such as CORS header mismatches and API design issues, paving the road for full integration ahead. Right now, the front-end is now able to display real expiration dates fetched from the API.The back-end API had quite a bit of work done to it as well. Logic has been added for when items are replaced into the fridge, ensuring that the item count and expiry dates remain correct even when the same item is removed and placed back into the fridge. This is done by storing the state of the fridge – new items are only added to the tally when it is in “add” mode, i.e. when the user is loading new groceries from the store. All other additions in the “track” mode are considered replacements of previous removals.

We’re still healthy in terms of schedule, but with just a bit over a month left, time can get a little tight if we are not careful. Going forward, we will be integrating the back-end with the Jetson and CV system, and I will also continue working with Alex to bring other aspects of the front-end into fruition, such as editing previous transactions.

Samuel’s Status Report – 26 Mar 22

During last week’s status report, I mentioned how we needed to find a dataset which exposed the network to a wider variety of fruit.

Samuel’s Status Report – 19 Mar 22

This week, was a relatively productive one: I managed to train the network on the “silvertray” dataset (https://www.kaggle.com/datasets/chrisfilo/fruit-recognition) which produced relatively robust results on test data that the network had never seen before (a green label indicates accurate detection; here we had 100% accuracy on test data).

Of course, the test data also involved the same silver trays that the algorithm trained on, so a high accuracy is expected.

I then moved on to making it perform detection using real-world data, on our C++ application with our webcam, and these are results!

As visible in the images above, the NN is able to detect the fruits accurately on in a real-world situation (including a noisy non-white background WITHOUT segmentation applied). That being said, there are some inaccuracies/misdetections such as with the orange above despite the frames being very similar. I describe needed improvements later below.

With this, we are currently on track towards a working prototype, although we could probably train the network to handle more classes with self-collected or web-procured data.

Next week, we will begin integration of the various components together, and I will work on several improvements to the current CV algorithm/setup:

  1. Include a “change detection” algorithm that will detect when significant changes appear; this will allow us to tell if a fruit is needing to be scanned.
  2. Normalization of the image before processing; this will help reduce issues with random lighting changes, but might require that the network be retrained
  3. Build the actual rig with a white background and test the algorithm on that
  4. If necessary, change to using a silver tray or silver-colored background similar to the network’s training set, and/or collect our own datasets.

Alex’s Status Report – 26 Mar 22

This week, we did an ethics study on our product and learned about how to make more ethical products.

I also worked on integrating the front end with the back end API. I’m a little behind schedule with this, but this was because I didn’t have the API earlier so I just need to work through this quickly. Unfortunately the API is still incomplete, so I will just have to work through what I can now. This week, we got the first endpoint up to tell us when food is going to expire and adds it to the calendar.

Oliver’s Status Report – 19 Mar 2022

I did not make as much progress this week as I had planned for due to an illness from Wednesday (Mar 16) till Saturday (Mar 19). However, despite that, I did manage to get some work done and achieve the progress we needed this week to keep us from falling behind.

Specifically, I brought the back-end API online on a server connected to the Internet, allowing for integration process with the front-end and the Jetson to begin. For example, calls to the API can now be made as follows:

$ curl -u "<secret key redacted>":"" -d "" https://fresheyes.oliverli.dev/item/2/
{"id":2,"name":"Apple","shelfLife":7,"unit":"piece","itemExpiry":[{"expiry":1648050152638,"quantity":5},{"expiry":1648351218448,"quantity":2}]}

This fetches all details for items of ID 2, which in our example here consist of apples. This data, including the expiration dates, are all returned in JSON format which can be easily parsed by a JavaScript front-end and presented to the user visually.

I also implemented enough remaining API endpoints to enable us to begin the integration process meaningfully. Specifically, there are now API endpoints analogous to CRUD – create, read, update, and delete, the 4 essential operations on the various resources. Although the back-end is still incomplete, this means that my focus from now on is the key application logic instead of lengthy boilerplate, which should progress substantially faster. I will also be working on the front-end integration together with Alex, so as to speedily unblock his work and enable him to continue with the front-end.

Besides the code, I also worked on the ethics assignment this week. Thinking about the ethical implications of the project was a new and interesting take, since I did not initially think this project could raise any ethical concerns at all. However, thinking critically, there were indeed aspects of personal data collection that can become problematic, making the ethics assignment an enlightening endeavor all things considered.

Samuel’s Status Report – 19 Mar 22

This week, I focused heavily on getting the neural network to work properly. In the beginning of the week, I successfully trained the neural network on the new ResNet18 architecture (as opposed on the old one that did not work). After I realized that it didn’t work as well as expected on real data, I swapped to a more advanced ResNet50 architecture, but that did not seem to help it either.

It was then that I began to suspect something else was wrong besides the the network itself, because the networks kept reporting a 90+% validation accuracy, but whenever I tested the code, even on training images. This hinted at a problem with my testing code/script. Eventually, I realized that during the network training process, we were passing in normalized images, and the network was training on that; once I changed my test/evaluation script to feed normalized images into the network, and everything worked very well!

However, as I began testing the network on various images, we realized that the network was not very robust on external data:

After scrutinizing the dataset, we realized that the dataset was not good enough, and was subject to some major flaws that made it susceptible to overfitting. Firstly, it was a 360 degree shot of a single fruit per category, so even though there were many images of fruit, the network was fed only one example of something from that fruit category, thus making it hard for the network to generalize based on colour, shape etc.

To resolve this problem, I would need to search for more datasets, parse them, and train our network on them. This will be my focus for next week. Currently, I have found several datasets; however, they each have their own issues. The most promising one I have found so far is very similar to our use-case, with images of fruits taken from a top-down view, but has a reflective silver tray background which is very hard to segment away. Some pictures also have groups of fruit:

I will first try training the network on center-cropped and resized images and if that does not work, I will try algorithms like Otsu thresholding on saturation value, or GrabCut, to segment away the background.

Samuel’s Status Report – 5 Mar 2022

This week, we spent most of our time writing up our design review report. Although a lot of the main content had been covered in our design review presentation, the devil was in the details for this report. In particular, we needed to make our block diagrams a lot more detailed since the ones we used in the slides were merely summaries.

We were very thankful that the deadline for the report got extended as that reduced the amount of stress we had, and allowed us to write a more polished report.

On the implementation side, I am slightly “behind schedule” in the sense that I was not able to get as much work done on the new neural network implementation as I had hoped to, because I was focusing on the report instead. However, we are still ahead of schedule since we already have an implementation going.

Next week, I will focus on implementing and training the ResNet18 network, and then testing the accuracy on a self-collected dataset of various fruits.

Oliver’s Status Report – 26 Feb 2022

This week, I have brought our back-end Express code-base to strict, 100%, type-safety. This type-safety is also enforced using automated code linters, specifically eslint and prettier, which are automatically run after each commit. This enforces a standardized and readable code style, ensures that strict type-safety is maintained, and even catches common bugs such as misuse of “null-able” values before the code is even merged into master.

In a large enterprise context, such type-checking and automated linting is a vital part of the development process, as it ensures a consistent code style and enforces a common standard across all developers. Even within this project, with a team of 3, each of us may write code in very different ways. Using an automated linter therefore automatically and safely transforms the written code to conform to our standard, ensuring maximum developer productivity across all 3 of us.

A stretch goal would be to extend the linting process to require automated tests, and to execute these automated process as part of a Continuous Integration/Continuous Deployment (CI/CD) process with each commit and each merge. This is another standard operating practice in fast moving and agile enterprise environments. However, considering the scale and timeframe of our project, I do not see the need to enforce this level of rigor at this point in time.

I am currently on schedule and am well poised to deliver on the back end APIs. Next week, I will focus on delivering a key set of API endpoints that Alex can integrate into the front end.

Samuel’s Status Report – 26 Feb 2022

The highlight of this week for me was delivering the Design Review presentation. I think I did quite well for the presentation, with my teammates and Professor commenting that the presentation was polished, with good graphics and content. We are currently working on the design report, and will use the content of the design presentation to write it.

On the technical side, I was able to make significant progress on the PyTorch port for the CV application, which was coded in C++ so that it can run optimized code on the Jetson, for maximum speed. The C++ application is now able to run the trained PyTorch model and spit out a set of predictions for the top 5 highest probability classes.

There were several challenges with the porting process, including the lack of good PyTorch documentation, which resulted in it being very difficult to figure out how to properly convert between C++ formats (cv2 to torch Tensor for example) and also important considerations in ensuring that the model can be serialized properly for running in C++ (in particular, no nested functions etc.). This is a lesson learnt on the importance of good documentation, and the pain/need of having to pour through various forums and articles as a result.

However, after training and testing the network, I began to realize big problems with the trained model. Most notably, the model failed to produce correct predictions. After consulting with Prof Mario’s PhD student, we realized that we were using a highly customized model that was not designed properly, and was not even a proper “ResNet” (lacking fully residual layers). To this end, he advised us to use other preexisting models like ResNet18 or AlexNet. This is a lesson learnt as to not blindly copy code over intern

Next week, I will focus on trying to train our data on either ResNet18 or AlexNet, as well as test it in the new C++ classifier. (There is also a Python one for quick testing, in case the C++ one still has bugs). Hopefully I will be able to train up a network that will achieve our desired accuracy of 85% (the network itself should reach about 95% validation accuracy).

Fortunately, despite this setback, we are currently still on schedule, because we were previously ahead of schedule with the successful porting of the C++ application.

Alex’s Status Report – 19 Feb 22

I worked on a significant portion of the front end, and was able to get a live demo hosted at https://capstone.astrasser.com:2096/

This week I finished the typescript for the site design. I used typescript since in the past it  has caught lots of bugs without needing to run and debug for me. Although it took a while to set up, it will pay off in the long run.

Additionally, setting up the domain forwarding was difficult for the demo, but will also speed up development a lot, as it allows me to quickly test on the tablet.

Next week, I will work on integrating the code with the API endpoints. I’m slightly ahead of schedule, but need to work hard since the rest of the semester will get busier.

Oliver’s Status Report – 19 Feb 22

This week, I defined the database schema, together with data relations, in a Prisma file. Defining the schema as code in this way also allows for easy tracking in a VCS e.g. Git of any changes, allows for safer database migrations as the schema changes, and also allows other group members to speedily spin up a development database for their own use.

In addition, I have decided upon an Express.js stack, using TypeScript with Prisma as the ORM. Using Prisma and an ORM abstracts away the complexity of crafting SQL queries, and also protects the application from SQL injection attacks by design. It even provides type safety, which together with TypeScript provides for full type-safety across the backend. I have spun up a starting Express application with Prisma and the schema, allowing me to continue building out the application. I chose TypeScript for its type-safety guarantee and the extensive standard library provided by JavaScript, and I chose the Express framework because it has great support for API endpoint development, which will form the vast majority of the backend work.

In the coming week, I will implement and bring online the first few API endpoints, allowing for some rudimentary functionality and testing after integration.