Skip to content

Commit

Permalink
Transition Update
Browse files Browse the repository at this point in the history
  • Loading branch information
KalyanMurapaka45 committed Jan 4, 2024
1 parent 57ee861 commit cfcafcb
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 349 deletions.
43 changes: 16 additions & 27 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import os
import sys
import subprocess
from PIL import Image
import google.generativeai as genai
from flask import Flask, render_template,request

# Setting Gemini Large Language Model Credentials
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Configure API key
vision_model = genai.GenerativeModel('gemini-pro-vision') # Initialize Gemini Pro Vision Model
text_model = genai.GenerativeModel('gemini-pro') # Initialize Gemini Pro Model
from src.utils import gen_from_image, gen_from_text
from flask import Flask, render_template,request,redirect,url_for

app = Flask(__name__)

def gen_from_image(prompt,imagefile):
pass

def gen_from_text(prompt):
pass

@app.route('/')
def index():
return render_template('index.html')

@app.route('/medrecog')
@app.route('/redirect')
def redirect_to_landing():
return redirect(url_for('landing'))

@app.route('/landing')
def landing():
return render_template('landing.html')

@app.route('/medrecog', methods=['GET', 'POST'])
def medrecog():
if request.method == 'POST':
med_prompt = '''
Expand All @@ -36,19 +32,17 @@ def medrecog():
validation_prompt = f"Check if the provided description is related to the medical field. Just Reply with 'Yes' or 'No'. Response: {response}"
image_file = request.files['file']
imagefile = Image.open(image_file)
response = gen_from_image(med_prompt,imagefile)
response = gen_from_image(med_prompt, imagefile)
validation_response = gen_from_text(validation_prompt)

if validation_response == 'Yes':
render_template('medrecog.html',response=response)
return render_template('medrecog.html', response=response)
else:
render_template('medrecog.html',response="Please provide a valid medical image.")

render_template('medrecog.html')
return render_template('medrecog.html', response="Please provide a valid medical image.")

@app.route('/conditional')
return render_template('medrecog.html')

@app.route('/', methods=['GET', 'POST'])
@app.route('/conditional', methods=['GET', 'POST'])
def conditional():
if request.method == 'POST':
try:
Expand Down Expand Up @@ -79,17 +73,12 @@ def conditional():
- Refrain from presenting inaccurate or ambiguous information.
- Ensure the query is focused and not overly broad."""

# Get Gemini response
gemini_response = gen_from_text(prompt)

return render_template('index.html', user_input=user_input, response=gemini_response)

return render_template('index.html')

@app.route('/chatbot')
def chat():
pass


if __name__ == '__main__':
app.run(debug=True)
Empty file.
Empty file.
Empty file.
15 changes: 14 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from src.logger import logging
from sklearn.metrics import accuracy_score
from src.exception import customexception
import google.generativeai as genai

genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Configure API key
vision_model = genai.GenerativeModel('gemini-pro-vision') # Initialize Gemini Pro Vision Model
text_model = genai.GenerativeModel('gemini-pro')

def save_object(file_path, obj):
try:
Expand Down Expand Up @@ -35,4 +40,12 @@ def load_object(file_path):
return pickle.load(file_obj)
except Exception as e:
logging.info('Exception Occured in load_object function utils')
raise customexception(e,sys)
raise customexception(e,sys)

def gen_from_image(prompt,imagefile):
vresponse = vision_model.generate_content(prompt, imagefile)
return vresponse.text

def gen_from_text(prompt):
tresponse = text_model.generate_content(prompt)
return tresponse.text
62 changes: 0 additions & 62 deletions static/landingstyle.css

This file was deleted.

4 changes: 0 additions & 4 deletions static/script2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ document
document.getElementById("openHealthText").style.opacity = "1";
}, 100);
}, 400);

setTimeout(function () {
window.location.href = "landing1.html";
}, 4000);
});
Loading

0 comments on commit cfcafcb

Please sign in to comment.