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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
37 changes: 37 additions & 0 deletions cal_predict/cal_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pickle
import pandas as pd
from fastapi import FastAPI
from pydantic import BaseModel

# Initialize FastAPI app
app = FastAPI()

# Load model once at startup
def load_model():
path = 'calorie_model.pkl'
with open(path, 'rb') as f:
return pickle.load(f)

model = load_model()

# Define request model
class InputData(BaseModel):
Dish_Weight: float
Protein: float
Fat: float
Carbohydrates: float
Fiber: float

@app.get("/")
def home():
return {"message": "Calorie Prediction API is running!"}

@app.post("/predict")
def predict_calories(data: InputData):
df = pd.DataFrame([data.model_dump()]) # Use model_dump() instead of .dict()
pred = model.predict(df)
return {'Predicted Calories': pred[0]}

if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
Binary file added cal_predict/calorie_model.pkl
Binary file not shown.
17 changes: 17 additions & 0 deletions cal_predict/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use an official Python runtime as a parent image
FROM python:3.10.0

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Expose the FastAPI default port
EXPOSE 8000

# Run the FastAPI application
CMD ["python", "cal_api.py"]
6 changes: 6 additions & 0 deletions cal_predict/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi
uvicorn
numpy
pandas
pydantic
scikit-learn
41 changes: 41 additions & 0 deletions fit-bite-web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
env: {
browser:true,
node: true,
es2021: true,
},
extends: ["eslint:recommended", "plugin:react/recommended", "next/core-web-vitals"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
{
files: ["*.mjs"],
parserOptions: {
sourceType: "module",
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: [
"react"],
rules: {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
// allow jsx syntax in js files (for next.js project)
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],},
settings: {
react: {
version: "detect",
},
},
};
3 changes: 3 additions & 0 deletions fit-bite-web/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "plugin:react-hooks/recommended"]
}
36 changes: 36 additions & 0 deletions fit-bite-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
34 changes: 34 additions & 0 deletions fit-bite-web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Loading