Inspiration

I have a chronic condition where I am forced to avoid certain foods. I often struggle with picking out foods I can eat and setting a diet plan. A lot of apps don't account for restrictions due to certain conditions like this, so I wanted to create an app that solves that problem.

What it does

The app will take your basic demographic information (age, weight, and height), any dietary restrictions you have, and what your goal is. This information is sent to an ML model that I made using CreateML, which will provide recommendations on foods to avoid and foods to eat. These recommendations and your diet goal are then sent to GPT-4, which generates a comprehensive diet plan.

How I built it

I used SwiftUI and Xcode to create the basic UI of the app. The main functionality of the app comes from the two models I made. First, I typed up all the demographic information and dietary restriction options as well as the recommendations I wanted the model to return on what to avoid and what to eat. Basically, all the features of the dataset are the demographic information and the restrictions. The targets were Avoid and Recommend, where Avoid had a list of what types of food to avoid, and Recommend had a list of what types of food to eat. I gave this information to ChatGPT and told it to create training data that I can use to train the model. I fed the training and testing data into CreateML to make the models, one for Avoid and one for Recommend. I used CoreML to implement the models into my code, and I used OpenAI's API to integrate GPT-4 into the app.

Challenges I ran into

I struggled a lot when I was creating the ML model and integrating it into the code. Originally, I had a binary target variable for each recommendation (e.g. binary target for Avoid Sugar, Recommend Protein, etc). This meant I had to deal with a lot of models, which slowed down the app and also made integrating them a lot more complicated. I decided to simplify this by combining all the binary avoid targets and all the binary recommend targets. I was considering combining all the recommendations into one, but I didn't want ChatGPT to start hallucinating or make a mistake and create an inaccurate dataset. I also had trouble getting the API key to work as it wasn't able to connect for a while, but eventually I was able to fix the issue with my integration of the API key.

Accomplishments that I'm proud of

I'm proud of being able to integrate my own ML model into my app. I could've easily just sent everything to GPT-4 and generate a diet plan, but having the model as a middleman allowed me to explore a different area of coding that I wasn't familiar with. I think it also sets me up for the future because an ML model that's trained on a real dataset will be a lot stronger than just sending everything to GPT-4.

What I learned

I learned about how to use CreateML to make ML models and I also learned how to use CoreML to integrate those models.

What's next for Diet Planner

I first want to make the ML model more accurate and based on real data. I also want there to be more customizability for the user. I was thinking of having the user type in specifically what their more complex restrictions are if they don't find the correct options in the drop-down menu, which will be sent to GPT-4 to create a comprehensive diet plan based on their more complex restrictions. I also want to add more features like a health tracker and a fitness plan.

Built With

  • coreml
  • createml
  • openai
  • swiftui
  • xcode
Share this project:

Updates