Giter VIP home page Giter VIP logo

notsointresting / calories_advisor_using-gemini_pro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anupriya7566/calories_advisor_using-gemini_pro

0.0 0.0 0.0 127.28 MB

Shell 0.02% JavaScript 0.19% C++ 5.06% Python 86.05% Perl 0.02% C 4.68% Fortran 0.03% Tcl 1.75% PowerShell 0.01% Forth 0.01% CSS 0.01% Makefile 0.06% HTML 0.17% Smarty 0.01% CMake 0.01% DTrace 0.01% Batchfile 0.01% Cython 1.85% Roff 0.08% Meson 0.01%

calories_advisor_using-gemini_pro's Introduction

Health Management APP

Introduction

This code sets up a Streamlit web application for a "Calories Advisor APP." The purpose of the app is to allow users to input a prompt and upload an image of food items. The app then utilizes Google Gemini Pro Vision API to analyze the image, identify food items, calculate the total calories, and provide advice on whether the food is good for health or not. The user interface includes input fields for the prompt and image upload, as well as a button to trigger the analysis. Once the analysis is complete, the app displays the response, which includes details of the food items detected, their respective calorie counts, and advice on their healthiness.

Key Concepts

Streamlit :

Streamlit is an open-source Python library that allows you to create web applications for machine learning and data science projects. It provides a simple and intuitive way to build interactive and customizable user interfaces.

Google Gemini Pro Vision API :

The Google Gemini Pro Vision API is a powerful tool for image analysis and recognition. It can identify objects, faces, and text in images, as well as provide information about their attributes and characteristics.

PIL (Python Imaging Library) :

PIL is a library in Python that adds support for opening, manipulating, and saving many different image file formats. It provides a wide range of image processing capabilities, including resizing, cropping, and enhancing images.

Code Structure

The code is structured as follows:

  1. Import the necessary libraries and modules:

    • dotenv: A library for loading environment variables from a .env file.
    • streamlit: The Streamlit library for creating web applications.
    • streamlit_authenticator: A library for authenticating users in Streamlit apps.
    • os: The OS module for interacting with the operating system.
    • google.generativeai: The Google Gemini Pro Vision API module for image analysis.
    • PIL: The Python Imaging Library for image processing.
  2. Configure the Google Gemini Pro Vision API by loading the API key from the environment variables.

  3. Define a function get_gemini_response that takes an input prompt and an image as parameters. This function uses the Google Gemini Pro Vision API to generate a response based on the input prompt and the image.

  4. Define a function input_image_setup that takes an uploaded file as a parameter. This function checks if a file has been uploaded, reads the file into bytes, and returns the image parts.

  5. Initialize the Streamlit app and set the page configuration.

  6. Create the user interface:

    • Display the header "Calories Advisor APP".
    • Create an input field for the prompt.
    • Create a file uploader for the image.
    • Display the uploaded image, if available.
    • Create a submit button "Tell me the total calories".
  7. Define an input prompt that explains the expected format of the prompt and the desired output.

  8. If the submit button is clicked, call the input_image_setup function to set up the image data.

  9. Call the get_gemini_response function to get the response from the Google Gemini Pro Vision API.

  10. Display the response in a subheader and write it to the Streamlit app.

Conclusion

This code sets up a Streamlit web application for a "Calories Advisor APP" using the Google Gemini Pro Vision API to analyze images of food items and provide advice on their healthiness. It allows users to input a prompt and upload an image, displaying the API response. This code provides a foundation for building nutrition or health-related applications based on food image analysis.

calories_advisor_using-gemini_pro's People

Contributors

anupriya7566 avatar notsointresting avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.