<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhinav Mathur</title>
    <description>The latest articles on DEV Community by Abhinav Mathur (@abhinav_mathur).</description>
    <link>https://dev.to/abhinav_mathur</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2141320%2Fb60b12a8-d5ca-4aa0-9ed7-41cda1f9da1e.jpg</url>
      <title>DEV Community: Abhinav Mathur</title>
      <link>https://dev.to/abhinav_mathur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhinav_mathur"/>
    <language>en</language>
    <item>
      <title>Multiple Disease Prediction App</title>
      <dc:creator>Abhinav Mathur</dc:creator>
      <pubDate>Tue, 01 Oct 2024 07:14:30 +0000</pubDate>
      <link>https://dev.to/abhinav_mathur/multiple-disease-prediction-app-2l6l</link>
      <guid>https://dev.to/abhinav_mathur/multiple-disease-prediction-app-2l6l</guid>
      <description>&lt;p&gt;&lt;strong&gt;In this guide, we'll show you how to install and run a multiple disease prediction web app that detects Parkinson's Disease, Heart Disease, and Diabetes. The app is hosted here and you can also run it locally by cloning the GitHub repository.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python: Ensure that Python (version 3.7 or above) is installed on your system. You can download it here.&lt;/li&gt;
&lt;li&gt;pip: This is typically installed with Python. To check if you have pip installed, run pip --version in your terminal.&lt;/li&gt;
&lt;li&gt;Streamlit: Streamlit is the framework used to build this web app. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install it using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Steps to Install and Run
&lt;/h2&gt;

&lt;p&gt;Clone the Repository&lt;/p&gt;

&lt;p&gt;First, clone the GitHub repository for the app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/Maniac1769/public_ml_web_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate into the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd public_ml_web_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the Required Dependencies&lt;br&gt;
The project uses a few Python packages which are listed in the requirements.txt file. To install all the required dependencies, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the App&lt;br&gt;
Once the dependencies are installed, you can run the app using Streamlit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run mdps_public.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will launch the app in your browser at &lt;a href="http://localhost:8501/" rel="noopener noreferrer"&gt;http://localhost:8501/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the App
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prediction Options: You will see three different disease prediction sections for Parkinson's Disease, Heart Disease, and Diabetes.&lt;/li&gt;
&lt;li&gt;Input Fields: Enter the required medical parameters in the input fields, such as age, glucose levels, etc., depending on the disease you want to check for.&lt;/li&gt;
&lt;li&gt;Results: After entering the values, click on the Predict button to get the prediction result.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's it! With these simple steps, you can run the Multiple Disease Detection app locally. Happy coding!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>Medical Disease/Injury Analysis App using Gemini API</title>
      <dc:creator>Abhinav Mathur</dc:creator>
      <pubDate>Sun, 29 Sep 2024 11:35:38 +0000</pubDate>
      <link>https://dev.to/abhinav_mathur/medical-diseaseinjury-analysis-app-using-gemini-api-d08</link>
      <guid>https://dev.to/abhinav_mathur/medical-diseaseinjury-analysis-app-using-gemini-api-d08</guid>
      <description>&lt;p&gt;In recent years, the integration of AI with healthcare has brought transformative potential in medical diagnostics. With the ability to analyze complex medical images, AI-driven applications can assist doctors and specialists in identifying diseases and recommending potential treatments. In this blog post, we’ll explore how to build a Streamlit-based Medical Disease/Injury Analysis App that leverages Google's Gemini API to provide intelligent image analysis.&lt;/p&gt;

&lt;p&gt;This app is designed to showcase the capabilities of AI in processing medical images and generating insightful analyses, using the Generative AI from Google. The app can be used to upload medical images, analyze them, and provide structured findings based on AI's interpretation, all while emphasizing the importance of consulting with a medical professional before making decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of the App
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Medical Image Uploading:&lt;/strong&gt; Users can upload medical images (JPEG/PNG) for analysis.&lt;br&gt;
&lt;strong&gt;AI-Powered Image Analysis:&lt;/strong&gt; The app uses the Google Gemini API to analyze medical images and generate insights.&lt;br&gt;
Recommendations: Based on the AI’s analysis, the app can suggest potential further steps like treatments or tests.&lt;br&gt;
&lt;strong&gt;Safety-First:&lt;/strong&gt; Includes filters to block harmful content such as hate speech, harassment, and explicit materials.&lt;br&gt;
Easy-to-Use Interface: Built using Streamlit for an intuitive and responsive UI.&lt;br&gt;
Prerequisites&lt;br&gt;
&lt;strong&gt;API Access:&lt;/strong&gt; You’ll need access to Google’s Generative AI API (Gemini).&lt;br&gt;
&lt;strong&gt;Python Setup:&lt;/strong&gt; Ensure you have Python installed on your system.&lt;br&gt;
Streamlit and Other Dependencies: Install Streamlit and other necessary libraries like Google’s Generative AI client using requirements.txt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;google.generativeai
protobuf==3.20.*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step-by-Step Breakdown
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configuring the Gemini API&lt;/strong&gt;
To begin, we configure the Gemini API with an API key. This key is essential for authentication and communicating with Google’s model.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import google.generativeai as genai
from api_key import api_key

genai.configure(api_key=api_key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API uses a predefined system prompt that guides the AI to behave like a medical professional, ensuring that it provides a structured and informative analysis of the medical images uploaded.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up the System Prompt&lt;/strong&gt;
The system prompt is the "script" that instructs the AI on how to behave. In this case, the AI behaves as a medical professional tasked with analyzing medical images.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;system_prompt = """
WE KNOW YOU ARE AN AI BUT RIGHT NOW YOU BEHAVE LIKE A MEDICAL PROFESSIONAL...
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prompt ensures that the AI provides detailed image analysis while following medical guidelines, documenting findings, and suggesting appropriate actions or treatments.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Implementing the Streamlit App&lt;/strong&gt;
The app is built using Streamlit, a Python library that makes it easy to create web applications. The app interface allows users to upload a medical image (JPEG/PNG) and generates a detailed AI-powered analysis upon submission.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the User Interface&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from pathlib import Path

st.set_page_config(page_title="VitalImageAnalytics", page_icon=":robot:")
st.image("OIG2.2.jpeg")
st.title(" 🧑‍⚕️Vital❤️Image📷 Analytics📊🧑‍⚕️ ")
st.subheader("An application that can help users to identify medical images")
uploaded_file = st.file_uploader("Upload the medical image for analysis", type=['png', 'jpeg', 'jpg'])
submit_button = st.button("Generate the analysis")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This snippet configures the Streamlit app to display a title, a subheader, and an image uploader for users to input their medical images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Upload and Analysis&lt;/strong&gt;&lt;br&gt;
When the user uploads an image and clicks the "Generate the analysis" button, the app passes the image to the Gemini API for analysis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if submit_button:
    image_data = uploaded_file.getvalue()
    st.image(image_data)
    image_parts = [{"mime_type": "image/jpeg", "data": image_data}]

    prompt_parts = [image_parts[0], system_prompt]
    response = model.generate_content(prompt_parts)

    if response:
        st.title("Here is the analysis based on your image: ")
        st.write(response.text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI processes the image and generates a structured response, following the system prompt’s guidelines.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Gemini API Configuration and Safety Settings&lt;/strong&gt;
The Gemini API model is configured with specific settings for optimal performance, including temperature, top-k sampling, and maximum output tokens. The app also enforces safety settings to filter out inappropriate content.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generation_config = {
  "temperature": 0.4,
  "top_p": 1,
  "top_k": 32,
  "max_output_tokens": 4096,
}

safety_settings = [
  {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
  {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
  {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
  {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
]

model = genai.GenerativeModel(model_name="gemini-1.5-flash",
                              generation_config=generation_config,
                              safety_settings=safety_settings)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These settings help ensure that the analysis remains safe and appropriate for the medical context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the Application
&lt;/h2&gt;

&lt;p&gt;Once all the components are set up, you can run the app locally by executing the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will launch the Streamlit app in your browser, where you can upload medical images and get detailed AI-generated analysis reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This project demonstrates how AI can assist in the medical field by analyzing images and providing recommendations. However, it’s essential to note that this app is not meant for real-world medical diagnosis. Its primary goal is to showcase the potential of AI in healthcare and how generative models like Gemini can be utilized for medical image analysis.&lt;/p&gt;

&lt;p&gt;For any clinical decision-making, it's critical to always consult with a licensed medical professional.&lt;/p&gt;

&lt;p&gt;By integrating powerful AI tools with intuitive platforms like Streamlit, developers can create innovative applications that make complex tasks—such as medical image analysis—more accessible and automated.&lt;/p&gt;

&lt;p&gt;Note: If you'd like to build this app yourself, don't forget to set up the api_key.py file with your own Gemini API key for proper functionality.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>data</category>
      <category>genaai</category>
      <category>github</category>
    </item>
  </channel>
</rss>
