Spaces:
Sleeping
Sleeping
Musharraf11
commited on
Commit
•
aa4ce78
1
Parent(s):
eca786c
Upload 13 files
Browse files- .env +1 -0
- .gitattributes +2 -35
- app.py +46 -0
- chatbot.py +111 -0
- feedback.csv +3 -0
- feedback.py +40 -0
- logo-hd.png +0 -0
- model.py +96 -0
- mysrap.py +83 -0
- prescription.py +106 -0
- requirements.txt +17 -0
- team.py +47 -0
- welcome.py +61 -0
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
GOOGLE_API_KEY="AIzaSyCH8lnRWjJe5vABq_uI0yIsXJz9dUhRK2A"
|
.gitattributes
CHANGED
@@ -1,35 +1,2 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
# Auto detect text files and perform LF normalization
|
2 |
+
* text=auto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_option_menu import option_menu
|
3 |
+
|
4 |
+
st.set_page_config(
|
5 |
+
page_title="PawSome-AI",
|
6 |
+
page_icon="🐾",
|
7 |
+
layout="centered",
|
8 |
+
initial_sidebar_state="auto"
|
9 |
+
)
|
10 |
+
|
11 |
+
# Display your logo at the top of the main page
|
12 |
+
# Adjust the path to your logo image
|
13 |
+
|
14 |
+
# st.header("Welcome to PawSome AI")
|
15 |
+
|
16 |
+
with st.sidebar:
|
17 |
+
selected = option_menu(
|
18 |
+
'PawSome AI',
|
19 |
+
['Welcome', 'Disease & Breed Detection', 'Petcare ChatBot', 'Prescription-Analyzer', 'Team Details', 'Feedback'],
|
20 |
+
icons=['house-door-fill', 'search', 'chat-right-fill', 'file-earmark-break-fill', 'info', 'star'],
|
21 |
+
menu_icon="🐶",
|
22 |
+
default_index=0
|
23 |
+
)
|
24 |
+
|
25 |
+
if selected == 'Welcome':
|
26 |
+
import welcome
|
27 |
+
welcome.welcome()
|
28 |
+
|
29 |
+
if selected == 'Disease & Breed Detection':
|
30 |
+
import model
|
31 |
+
model.model()
|
32 |
+
|
33 |
+
if selected == 'Petcare ChatBot':
|
34 |
+
import chatbot
|
35 |
+
chatbot.chatbot()
|
36 |
+
|
37 |
+
if selected == 'Prescription-Analyzer':
|
38 |
+
import prescription
|
39 |
+
prescription.presc_analyze()
|
40 |
+
|
41 |
+
if selected == 'Feedback':
|
42 |
+
import feedback
|
43 |
+
feedback.feedback()
|
44 |
+
if selected == 'Team Details':
|
45 |
+
import team
|
46 |
+
team.team_details()
|
chatbot.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def chatbot():
|
2 |
+
# Importing all the modules
|
3 |
+
import streamlit as st
|
4 |
+
from PyPDF2 import PdfReader
|
5 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
6 |
+
import os
|
7 |
+
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
8 |
+
import google.generativeai as genai
|
9 |
+
from langchain.vectorstores import FAISS
|
10 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
11 |
+
from langchain.chains.question_answering import load_qa_chain
|
12 |
+
from langchain.prompts import PromptTemplate
|
13 |
+
from dotenv import load_dotenv
|
14 |
+
import pyttsx3
|
15 |
+
|
16 |
+
def speak_response(response_content):
|
17 |
+
engine = pyttsx3.init()
|
18 |
+
engine.say(response_content)
|
19 |
+
engine.runAndWait()
|
20 |
+
|
21 |
+
# Load environment variables
|
22 |
+
load_dotenv()
|
23 |
+
api_key = os.getenv("GOOGLE_API_KEY")
|
24 |
+
genai.configure(api_key=api_key)
|
25 |
+
|
26 |
+
def get_pdf_text(pdf_docs):
|
27 |
+
text = ""
|
28 |
+
for pdf in pdf_docs:
|
29 |
+
pdf_reader = PdfReader(pdf)
|
30 |
+
for page in pdf_reader.pages:
|
31 |
+
text += page.extract_text()
|
32 |
+
return text
|
33 |
+
|
34 |
+
def get_text_chunks(text):
|
35 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=10000, chunk_overlap=1000)
|
36 |
+
chunks = text_splitter.split_text(text)
|
37 |
+
return chunks
|
38 |
+
|
39 |
+
def get_vector_store(text_chunks):
|
40 |
+
embedding_function = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
41 |
+
vector_store = FAISS.from_texts(text_chunks, embedding=embedding_function)
|
42 |
+
vector_store.save_local("faiss_index")
|
43 |
+
|
44 |
+
def get_conversational_chain():
|
45 |
+
prompt_template = """
|
46 |
+
Answer the question as detailed as possible from the provided context, make sure to provide all the details, if the answer is not in
|
47 |
+
provided context then go and find and provide the answer don't provide the wrong answer and your a expert in pet-care so make sure all your responses are within that.\n\n
|
48 |
+
Context:\n {context}?\n
|
49 |
+
Question: \n{question}\n
|
50 |
+
|
51 |
+
Answer:
|
52 |
+
"""
|
53 |
+
model = ChatGoogleGenerativeAI(model="gemini-1.5-pro-latest", temperature=0.3)
|
54 |
+
prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
55 |
+
chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
|
56 |
+
return chain
|
57 |
+
|
58 |
+
def user_input(user_question):
|
59 |
+
embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
60 |
+
new_db = FAISS.load_local("faiss_index", embeddings, allow_dangerous_deserialization=True)
|
61 |
+
docs = new_db.similarity_search(user_question)
|
62 |
+
chain = get_conversational_chain()
|
63 |
+
response = chain({"input_documents": docs, "question": user_question}, return_only_outputs=True)
|
64 |
+
return response["output_text"]
|
65 |
+
|
66 |
+
# Main function for the chatbot
|
67 |
+
st.title("Pet Care ChatBot 🐾")
|
68 |
+
st.subheader("Your AI-Powered Pet Care Assistant")
|
69 |
+
st.markdown("""
|
70 |
+
Welcome to the Pet Care ChatBot! Ask any question related to pet care, and our AI-powered assistant will provide you with detailed and accurate answers.
|
71 |
+
""")
|
72 |
+
voice_response = st.checkbox("Click for Voice Response")
|
73 |
+
|
74 |
+
if "messages" not in st.session_state:
|
75 |
+
st.session_state.messages = []
|
76 |
+
|
77 |
+
# Uncomment if you want to add your own-custom pdf:
|
78 |
+
# with st.form(key="uploader_form"):
|
79 |
+
# pdf_docs = st.file_uploader("Upload your PDF Files", accept_multiple_files=True)
|
80 |
+
# submit_button = st.form_submit_button(label="Submit & Process")
|
81 |
+
# if submit_button:
|
82 |
+
# if pdf_docs:
|
83 |
+
# with st.spinner("Processing..."):
|
84 |
+
# raw_text = get_pdf_text(pdf_docs)
|
85 |
+
# text_chunks = get_text_chunks(raw_text)
|
86 |
+
# get_vector_store(text_chunks)
|
87 |
+
# st.success("Processing completed successfully.")
|
88 |
+
# else:
|
89 |
+
# st.warning("Please upload at least one PDF file.")
|
90 |
+
|
91 |
+
# Display chat messages from history on app rerun
|
92 |
+
for message in st.session_state.messages:
|
93 |
+
with st.chat_message(message["role"]):
|
94 |
+
st.markdown(message["content"])
|
95 |
+
|
96 |
+
# React to user input
|
97 |
+
if prompt := st.chat_input("Ask a question from the PDF files"):
|
98 |
+
# Display user message in chat message container
|
99 |
+
st.chat_message("user").markdown(prompt)
|
100 |
+
# Add user message to chat history
|
101 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
102 |
+
|
103 |
+
response = user_input(prompt)
|
104 |
+
# Display assistant response in chat message container
|
105 |
+
with st.chat_message("assistant"):
|
106 |
+
st.markdown(response)
|
107 |
+
if voice_response:
|
108 |
+
speak_response(response)
|
109 |
+
|
110 |
+
# Add assistant response to chat history
|
111 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
feedback.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
name,email,feedback_type,message,timestamp
|
2 |
+
Boss,habii,Suggestion,great job guys,2024-06-20 22:26:46.126194
|
3 |
+
Boss,habii,Issue,great job guys cool,2024-06-20 22:27:24.377924
|
feedback.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from datetime import datetime
|
4 |
+
|
5 |
+
def feedback():
|
6 |
+
st.title("Feedback")
|
7 |
+
st.write("We value your feedback to help us improve PawSome-AI!")
|
8 |
+
|
9 |
+
# Feedback form
|
10 |
+
with st.form(key='feedback_form'):
|
11 |
+
name = st.text_input("Your Name")
|
12 |
+
email = st.text_input("Your Email")
|
13 |
+
feedback_type = st.selectbox("Type of Feedback", ["Suggestion", "Issue", "Other"])
|
14 |
+
message = st.text_area("Your Feedback")
|
15 |
+
submit_button = st.form_submit_button(label="Submit")
|
16 |
+
|
17 |
+
# After the user clicks the submit button
|
18 |
+
if submit_button:
|
19 |
+
feedback_data = {
|
20 |
+
"name": [name],
|
21 |
+
"email": [email],
|
22 |
+
"feedback_type": [feedback_type],
|
23 |
+
"message": [message],
|
24 |
+
"timestamp": [datetime.now()]
|
25 |
+
}
|
26 |
+
feedback_df = pd.DataFrame(feedback_data)
|
27 |
+
|
28 |
+
# Save the feedback to a CSV file
|
29 |
+
try:
|
30 |
+
existing_feedback_df = pd.read_csv("feedback.csv")
|
31 |
+
feedback_df = pd.concat([existing_feedback_df, feedback_df], ignore_index=True)
|
32 |
+
except FileNotFoundError:
|
33 |
+
pass
|
34 |
+
|
35 |
+
feedback_df.to_csv("feedback.csv", index=False)
|
36 |
+
|
37 |
+
st.success("Thank you for your feedback! We'll get back to you shortly.")
|
38 |
+
|
39 |
+
st.write("If you need immediate assistance, please contact us at: ")
|
40 |
+
st.markdown("[contact.pawsomeai@gmail.com](mailto:contact.pawsomeai@gmail.com)")
|
logo-hd.png
ADDED
model.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def model():
|
2 |
+
# Importing All the modules
|
3 |
+
import streamlit as st
|
4 |
+
import os
|
5 |
+
from PIL import Image
|
6 |
+
import google.generativeai as genai
|
7 |
+
from dotenv import load_dotenv
|
8 |
+
|
9 |
+
# Load all environment Variables
|
10 |
+
load_dotenv()
|
11 |
+
|
12 |
+
# Configuring the api key
|
13 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
14 |
+
|
15 |
+
# Function to load Gemini Vison Pro Vision Model and Get response
|
16 |
+
def get_gemini_response(image, prompt):
|
17 |
+
# Loading the desired Model
|
18 |
+
model = genai.GenerativeModel("gemini-pro-vision")
|
19 |
+
response = model.generate_content([image[0], prompt])
|
20 |
+
return response.text
|
21 |
+
|
22 |
+
# Function to extract data from Image Uploaded
|
23 |
+
def input_image_setup(uploaded_file):
|
24 |
+
# Check if a file has been uploaded
|
25 |
+
if uploaded_file is not None:
|
26 |
+
# Read the file into bytes
|
27 |
+
bytes_data = uploaded_file.getvalue()
|
28 |
+
image_parts = [
|
29 |
+
{
|
30 |
+
"mime_type": uploaded_file.type, # Get the mime type of the uploaded file
|
31 |
+
"data": bytes_data
|
32 |
+
}
|
33 |
+
]
|
34 |
+
return image_parts
|
35 |
+
else:
|
36 |
+
raise FileNotFoundError("No file uploaded")
|
37 |
+
|
38 |
+
# Initializing our Streamlit Prompt
|
39 |
+
st.title("Pet Image Analyzer")
|
40 |
+
st.write(
|
41 |
+
"""
|
42 |
+
Welcome to the Pet Image Analyzer! This tool uses advanced AI technology to analyze images of your pets
|
43 |
+
and provide insights into their breed, potential health issues, and more. Please upload an image of your pet
|
44 |
+
to get started.
|
45 |
+
"""
|
46 |
+
)
|
47 |
+
|
48 |
+
# File uploader for image input
|
49 |
+
uploaded_file = st.file_uploader("Choose a pet image...", type=["jpg", "jpeg", "png", "webp"])
|
50 |
+
image = None
|
51 |
+
|
52 |
+
if uploaded_file is not None:
|
53 |
+
image = Image.open(uploaded_file)
|
54 |
+
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
55 |
+
|
56 |
+
# Defining a System Prompt (pre-defined)
|
57 |
+
input_prompt = f"""Image: (content of the uploaded image)
|
58 |
+
|
59 |
+
Text: Analyze the image and provide the following information:
|
60 |
+
|
61 |
+
* Breed: Identify the breed of the animal in the image (if possible).
|
62 |
+
* Disease Detection: If the image shows a diseased area, identify the specific disease (if possible).
|
63 |
+
* Severity: If a disease is detected, assess the severity of the disease.
|
64 |
+
* Symptoms: Describe the common symptoms associated with the detected disease.
|
65 |
+
* Precautions: Recommend preventative measures to avoid the disease.
|
66 |
+
|
67 |
+
Give response with headings,
|
68 |
+
Inform the user if the image is not related to pet care.
|
69 |
+
"""
|
70 |
+
|
71 |
+
submit = st.button("Analyze Image")
|
72 |
+
Disclaimer = (
|
73 |
+
"**Disclaimer:** This application uses image analysis to provide potential information about your pet's health. "
|
74 |
+
"The results are for informational purposes only and should not be considered a replacement for professional veterinary diagnosis. "
|
75 |
+
"For any concerns about your pet's health, please consult a licensed veterinarian. They can conduct a thorough examination and provide personalized recommendations for your pet's well-being."
|
76 |
+
)
|
77 |
+
|
78 |
+
if submit:
|
79 |
+
if image:
|
80 |
+
with st.spinner("Analyzing Image..."):
|
81 |
+
image_data = input_image_setup(uploaded_file)
|
82 |
+
response = get_gemini_response(image_data, input_prompt)
|
83 |
+
st.subheader("Analysis Result:")
|
84 |
+
st.write(response)
|
85 |
+
st.warning(Disclaimer)
|
86 |
+
st.balloons()
|
87 |
+
else:
|
88 |
+
st.error("Please upload an image to proceed.")
|
89 |
+
else:
|
90 |
+
st.info("Upload an image of your pet to get started!")
|
91 |
+
st.write(
|
92 |
+
"""
|
93 |
+
To analyze your pet's image, click on the 'Choose a pet image...' button above and select an image file from your device.
|
94 |
+
Once the image is uploaded, click on 'Analyze Image' to receive detailed information about your pet.
|
95 |
+
"""
|
96 |
+
)
|
mysrap.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
from selenium import webdriver
|
5 |
+
from selenium.webdriver.chrome.service import Service
|
6 |
+
from selenium.webdriver.chrome.options import Options
|
7 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
8 |
+
import time
|
9 |
+
|
10 |
+
def search_medicine_supertails(medicine_name):
|
11 |
+
url = f'https://supertails.com/search?q={medicine_name}&page=1'
|
12 |
+
|
13 |
+
options = Options()
|
14 |
+
options.headless = True
|
15 |
+
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
|
16 |
+
|
17 |
+
try:
|
18 |
+
driver.get(url)
|
19 |
+
time.sleep(5) # Wait for the page to load completely
|
20 |
+
|
21 |
+
# Get the page source and parse it with BeautifulSoup
|
22 |
+
page_source = driver.page_source
|
23 |
+
soup_obj = BeautifulSoup(page_source, 'html.parser')
|
24 |
+
|
25 |
+
# Find all product elements
|
26 |
+
products = soup_obj.find_all('li', class_='findify-components-common--grid__column findify-components-common--grid__column-3 product-item')
|
27 |
+
|
28 |
+
product_name = []
|
29 |
+
product_price = []
|
30 |
+
product_link = []
|
31 |
+
|
32 |
+
for product in products:
|
33 |
+
# Find the first <a> tag directly after the <li> tag
|
34 |
+
link_tag = product.find_next('a', href=True)
|
35 |
+
if link_tag:
|
36 |
+
product_link.append('https://supertails.com' + link_tag['href'])
|
37 |
+
else:
|
38 |
+
product_link.append('N/A') # Append placeholder if link is missing
|
39 |
+
|
40 |
+
name_tag = product.find('h2', class_='findify-components--cards--product__title')
|
41 |
+
if name_tag:
|
42 |
+
product_name.append(name_tag.text.strip())
|
43 |
+
else:
|
44 |
+
product_name.append('N/A') # Append placeholder if name is missing
|
45 |
+
|
46 |
+
price_tag = product.find('div', class_='findify-components--cards--product--price__price findify-components--cards--product--price__sale-price')
|
47 |
+
if price_tag:
|
48 |
+
product_price.append(price_tag.text.strip())
|
49 |
+
else:
|
50 |
+
product_price.append('N/A') # Append placeholder if price is missing
|
51 |
+
|
52 |
+
df = pd.DataFrame({
|
53 |
+
'Product Name': product_name,
|
54 |
+
'Price': product_price,
|
55 |
+
'Link': product_link
|
56 |
+
})
|
57 |
+
|
58 |
+
return df
|
59 |
+
|
60 |
+
except Exception as e:
|
61 |
+
st.error(f'Error occurred: {e}')
|
62 |
+
return None
|
63 |
+
finally:
|
64 |
+
driver.quit()
|
65 |
+
|
66 |
+
def main():
|
67 |
+
st.title('Medicine Finder')
|
68 |
+
|
69 |
+
# Input field for medicine name
|
70 |
+
medicine_name = st.text_input('Enter the name of the medicine:')
|
71 |
+
|
72 |
+
if st.button('Search'):
|
73 |
+
# Call the scraper function
|
74 |
+
results_df = search_medicine_supertails(medicine_name)
|
75 |
+
|
76 |
+
# Display results
|
77 |
+
if results_df is not None and not results_df.empty:
|
78 |
+
st.dataframe(results_df)
|
79 |
+
elif results_df is not None:
|
80 |
+
st.write("No results found")
|
81 |
+
|
82 |
+
if __name__ == '__main__':
|
83 |
+
main()
|
prescription.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
from PIL import Image
|
4 |
+
import google.generativeai as genai
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
from mysrap import search_medicine_supertails
|
7 |
+
from google.generativeai.types import HarmCategory, HarmBlockThreshold
|
8 |
+
|
9 |
+
def presc_analyze():
|
10 |
+
# Load environment variables
|
11 |
+
load_dotenv()
|
12 |
+
|
13 |
+
# Configure the API key
|
14 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
15 |
+
|
16 |
+
# Function to load Gemini Vision Pro model and get response
|
17 |
+
def get_gemini_response(input_prompt, image_data, user_prompt):
|
18 |
+
# model = genai.GenerativeModel("gemini-pro-vision")
|
19 |
+
safety_settings={
|
20 |
+
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
|
21 |
+
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
|
22 |
+
# HarmCategory.HARM_CATEGORY_DANGEROUS: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
|
23 |
+
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
|
24 |
+
}
|
25 |
+
model = genai.GenerativeModel("gemini-pro-vision",safety_settings=safety_settings)
|
26 |
+
response = model.generate_content([input_prompt, image_data[0], user_prompt])
|
27 |
+
return response.text
|
28 |
+
|
29 |
+
# Function to extract data from uploaded image
|
30 |
+
def input_image_setup(uploaded_file):
|
31 |
+
if uploaded_file is not None:
|
32 |
+
bytes_data = uploaded_file.getvalue()
|
33 |
+
image_parts = [
|
34 |
+
{
|
35 |
+
"mime_type": uploaded_file.type,
|
36 |
+
"data": bytes_data,
|
37 |
+
}
|
38 |
+
]
|
39 |
+
return image_parts
|
40 |
+
else:
|
41 |
+
raise FileNotFoundError("No file uploaded")
|
42 |
+
|
43 |
+
def extract_medicine_names_heuristic(text):
|
44 |
+
import re
|
45 |
+
# Split based on common delimiters, numbers, or new lines
|
46 |
+
potential_medicines = re.split(r'\d+\.\s*|\n|\r|,', text)
|
47 |
+
# Clean up and filter out non-medicines
|
48 |
+
potential_medicines = [med.strip() for med in potential_medicines if med.strip() and med.lower() not in ["the", "to", "of", "and", "is"]]
|
49 |
+
return potential_medicines
|
50 |
+
|
51 |
+
# Streamlit app configuration
|
52 |
+
# st.set_page_config(page_title="Prescription & Medicine Information Extractor")
|
53 |
+
st.header("Prescription & Medicine Information Extractor")
|
54 |
+
|
55 |
+
user_prompt = "Give me the details about the Prescription and along with basic personal details and tell about medications and frequency in a proper tabular form"
|
56 |
+
uploaded_file = st.file_uploader("Choose a Prescription Image...", type=["jpg", "jpeg", "png"])
|
57 |
+
image = ""
|
58 |
+
if uploaded_file is not None:
|
59 |
+
image = Image.open(uploaded_file)
|
60 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
61 |
+
|
62 |
+
submit = st.button("Extract Information")
|
63 |
+
|
64 |
+
# System prompt for understanding prescriptions
|
65 |
+
info_prompt = """You are an expert in understanding prescriptions.
|
66 |
+
You will receive prescription images and answer questions based on them.
|
67 |
+
Please consider the following information: {user_prompt}"""
|
68 |
+
|
69 |
+
# System prompt for extracting medicine names (heuristic)
|
70 |
+
medicine_prompt = "Please list all the medications mentioned in the prescription.Make sure that you just give medicine name with strength."
|
71 |
+
|
72 |
+
if submit:
|
73 |
+
image_data = input_image_setup(uploaded_file)
|
74 |
+
|
75 |
+
# Extract information based on user prompt
|
76 |
+
info_response = get_gemini_response(info_prompt.format(user_prompt=user_prompt), image_data, "")
|
77 |
+
st.subheader("Extracted Information:")
|
78 |
+
st.write(info_response)
|
79 |
+
|
80 |
+
# Extract medicine names using a separate query
|
81 |
+
medicine_response = get_gemini_response(medicine_prompt, image_data, "")
|
82 |
+
medicine_names = extract_medicine_names_heuristic(medicine_response)
|
83 |
+
|
84 |
+
if medicine_names:
|
85 |
+
st.subheader("Medicine Names:")
|
86 |
+
# Store medicine names in a list
|
87 |
+
medicine_list = ", ".join(medicine_names)
|
88 |
+
st.write(medicine_list)
|
89 |
+
|
90 |
+
# Display at least 6-7 medicines with clickable links for each extracted medicine name
|
91 |
+
st.subheader("Medicines with Links:")
|
92 |
+
for medicine in medicine_names:
|
93 |
+
st.markdown(f"### {medicine}")
|
94 |
+
results_df = search_medicine_supertails(medicine)
|
95 |
+
if results_df is not None and not results_df.empty:
|
96 |
+
for index, row in results_df.head(7).iterrows():
|
97 |
+
st.markdown(f"[{row['Product Name']}]({row['Link']}) - {row['Price']} ₹")
|
98 |
+
else:
|
99 |
+
st.write(f"No results found for {medicine}")
|
100 |
+
else:
|
101 |
+
st.write("No medicine names found using the heuristic approach.")
|
102 |
+
|
103 |
+
st.balloons()
|
104 |
+
|
105 |
+
if __name__ == '__main__':
|
106 |
+
presc_analyze()
|
requirements.txt
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
streamlit-option-menu
|
3 |
+
google-generativeai
|
4 |
+
python-dotenv
|
5 |
+
langchain
|
6 |
+
PyPDF2
|
7 |
+
chromadb
|
8 |
+
faiss-cpu
|
9 |
+
langchain_google_genai
|
10 |
+
streamlit
|
11 |
+
pandas
|
12 |
+
beautifulsoup4
|
13 |
+
selenium
|
14 |
+
webdriver-manager
|
15 |
+
pyttsx3
|
16 |
+
langchain-community
|
17 |
+
requests
|
team.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import webbrowser
|
3 |
+
|
4 |
+
def team_details():
|
5 |
+
st.title("Our Team")
|
6 |
+
|
7 |
+
team_members = [
|
8 |
+
{
|
9 |
+
"name": "Mohammadi Shifa",
|
10 |
+
"role": "Lead Developer",
|
11 |
+
"description": "Shifa is passionate about building innovative solutions and has a strong background in web development and AI.",
|
12 |
+
"gmail": "shifamohammadi07@gmail.com",
|
13 |
+
"usn": "USN: A1234567"
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"name": "Harsha",
|
17 |
+
"role": "Data Scientist",
|
18 |
+
"description": "Harsha specializes in machine learning algorithms and data analysis. She enjoys tackling complex problems.",
|
19 |
+
"gmail": "harshasmith@gmail.com",
|
20 |
+
"usn": "USN: B2345678"
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"name": "Kishitj",
|
24 |
+
"role": "UI/UX Designer",
|
25 |
+
"description": "Kishitj brings creativity to our team with a focus on user experience and interface design.",
|
26 |
+
"gmail": "kishitj@gmail.com",
|
27 |
+
"usn": "USN: C3456789"
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"name": "Emily Brown",
|
31 |
+
"role": "Marketing Specialist",
|
32 |
+
"description": "Emily excels in digital marketing strategies and customer engagement, ensuring our app reaches a wide audience.",
|
33 |
+
"gmail": "emilybrown@gmail.com",
|
34 |
+
"usn": "USN: D4567890"
|
35 |
+
}
|
36 |
+
]
|
37 |
+
|
38 |
+
for member in team_members:
|
39 |
+
st.header(member["name"])
|
40 |
+
st.subheader(member["role"])
|
41 |
+
st.write(member["description"])
|
42 |
+
st.write(member["usn"])
|
43 |
+
if st.button(f"Contact {member['name']} via Gmail"):
|
44 |
+
webbrowser.open_new_tab(f"mailto:{member['gmail']}?subject=Regarding%20PawSome-AI%20App")
|
45 |
+
|
46 |
+
if __name__ == "__main__":
|
47 |
+
team_details()
|
welcome.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
def welcome():
|
4 |
+
# Logo and main heading
|
5 |
+
st.image("logo-hd.png", width=200)
|
6 |
+
st.title("Welcome to PawSome-AI 🐾")
|
7 |
+
st.write("Your AI-Powered Pet Care Assistant")
|
8 |
+
st.markdown("---") # Horizontal line
|
9 |
+
|
10 |
+
# Main layout with two columns
|
11 |
+
col1, col2 = st.columns(2)
|
12 |
+
|
13 |
+
# Key Features section centered (Column 1)
|
14 |
+
with col1:
|
15 |
+
st.markdown("""
|
16 |
+
<div style="background-color:#e5f7fa; padding:20px; border-radius:10px; text-align:center;">
|
17 |
+
<h3 style="color:#007a87;">Key Features</h3>
|
18 |
+
<p style="color:#333333;">Explore the capabilities that PawSome-AI offers to enhance your pet care experience:</p>
|
19 |
+
<ul style="text-align:left;">
|
20 |
+
<li><strong>Dog Breed Identification and Disease Detection</strong><br>
|
21 |
+
Upload images to identify your dog's breed and detect diseases. Get detailed information on symptoms, precautions, and treatments.</li><br>
|
22 |
+
|
23 |
+
<li><strong>Pet Care Chatbot</strong><br>
|
24 |
+
Interactive chatbot for pet-care-related queries and advice. Receive personalized recommendations on nutrition, grooming, behavior, and more.</li><br>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
""", unsafe_allow_html=True)
|
28 |
+
|
29 |
+
# Additional Key Features (Column 2)
|
30 |
+
with col2:
|
31 |
+
st.markdown("""
|
32 |
+
<div style="background-color:#e5f7fa; padding:20px; border-radius:10px;">
|
33 |
+
<h3 style="color:#007a87;">Additional Key Features</h3>
|
34 |
+
<ul style="text-align:left;">
|
35 |
+
<li><strong>Prescription Analyzer</strong><br>
|
36 |
+
Upload veterinary prescriptions to manage your pet's medications effectively
|
37 |
+
Get detailed information about medications listed in the prescription.
|
38 |
+
<br>
|
39 |
+
|
40 |
+
|
41 |
+
<li><strong>Contact and Feedback</strong><br>
|
42 |
+
Contact form for inquiries and feedback collection. Reach out to us for any questions or suggestions.</li><br>
|
43 |
+
|
44 |
+
<li><strong>Future Features</strong><br>
|
45 |
+
Planned enhancements to further assist pet owners. Suggestions are welcomed. </li><br>
|
46 |
+
</ul>
|
47 |
+
</div>
|
48 |
+
""", unsafe_allow_html=True)
|
49 |
+
|
50 |
+
# How to Use section centered (Spanning both columns)
|
51 |
+
st.markdown("""
|
52 |
+
<div style="background-color:#f9f9f9; padding:20px; border-radius:10px; text-align:center;">
|
53 |
+
<h3 style="color:#4d4d4d;">How to Use</h3>
|
54 |
+
<ul style="text-align:left;">
|
55 |
+
<li>Navigate through the app using the sidebar menu on the left.</li>
|
56 |
+
<li>Upload an image to detect dog breeds and diseases.</li>
|
57 |
+
<li>Interact with the chatbot for personalized pet care advice.</li>
|
58 |
+
<li>Use the Prescription Analyzer to manage your pet's medications.</li>
|
59 |
+
</ul>
|
60 |
+
</div>
|
61 |
+
""", unsafe_allow_html=True)
|