Gozie-MedicBot / app.py
EmmaGozie's picture
Update app.py
ea4e97a verified
import gradio as gr
import os
os.environ["KERAS_BACKEND"] = "tensorflow"
import keras
import keras_nlp
css = """
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
body::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-image: url('https://unsplash.com/photos/a-bunch-of-pills-are-in-a-glass-container-mfjoslXbb-8');
background-size: cover;
background-repeat: no-repeat;
opacity: 0.75; /* Faint background image */
background-position: center;
z-index: -1; /* Keep the background behind text */
}
.gradio-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh; /* Ensure the content is vertically centered */
}
"""
gemma_lm = keras_nlp.models.CausalLM.from_preset("hf://EmmaGozie/gemma-medic-bot-2b-en")
def launch(input):
template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
prompt = template.format(
instruction=input,
response="",
)
out = gemma_lm.generate(prompt, max_length=256)
ind = out.index('Response') + len('Response')+2
return out[ind:]
iface = gr.Interface(launch,
inputs="text",
outputs="text",
css=css,
title="Hey I am Gozie-medicbot πŸ‘‹ I can answer health-related questions, including drug usage, dosage, diseases, treatments, and side effects. Try me :)",
description="Gemma_2b_en is fine-tuned on a comprehensive medical Q&A dataset")
iface.launch()