|
import streamlit as st |
|
from PIL import Image |
|
import google.generativeai as genai |
|
|
|
from deep_translator import GoogleTranslator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
st.markdown(""" |
|
<style> |
|
input { |
|
unicode-bidi: bidi-override; |
|
direction: RTL; |
|
} |
|
label { |
|
direction: RTL; |
|
font-size: 54px; /* Updated font size here */ |
|
display: block; |
|
text-align: right; |
|
margin-top: 5px; |
|
margin-bottom: 5px; |
|
} |
|
.title { |
|
text-align: center; |
|
font-size: 40px; |
|
} |
|
div.stButton > button:first-child { |
|
background-color: #1640D6 !important; |
|
color: white !important; |
|
font-size: 40px !important; |
|
height: 1em !important; |
|
width: 3em; |
|
border-radius: 5px; |
|
border: none; |
|
} |
|
div.stButton { |
|
text-align: center; |
|
} |
|
div.stButton:hover { |
|
background-color: #11009E |
|
} |
|
|
|
/* Media query for responsiveness to mobile devices */ |
|
@media only screen and (max-width: 600px) { |
|
label { |
|
font-size: 18px; /* Adjusted font size for mobile devices */ |
|
} |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
st.markdown('<div class="title">Pezhma.ir</div>', unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
|
|
text_input2 = st.text_input('در صورتیکه نام آزمایشتان را بلدید، آنرا وارد کنید', placeholder='Liver function test (or LFT)') |
|
|
|
|
|
|
|
genai.configure(api_key="AIzaSyBd36RWeqDpLur3E7TTlX3wnyIh_rdhsU8") |
|
|
|
uploader_key = 'file_uploader' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Just Image", type=["jpg", "jpeg", "png"], key=uploader_key) |
|
|
|
mod = genai.GenerativeModel('gemini-pro-vision') |
|
|
|
txt = text_input2 |
|
|
|
l=[] |
|
g=[] |
|
|
|
if uploaded_file is not None: |
|
image = Image.open(uploaded_file) |
|
st.image(image, caption='Uploaded Image.', use_column_width=True) |
|
trans = GoogleTranslator(source='fa', target='en') |
|
|
|
g.append(txt) |
|
trans_text = trans.translate(g[0]) |
|
res = mod.generate_content(["" + trans_text, image], stream=True) |
|
res.resolve() |
|
l.append(res.text) |
|
if st.button('Report'): |
|
|
|
translator = GoogleTranslator(source='en', target='fa') |
|
|
|
translated_text = translator.translate(l[0]) |
|
|
|
|
|
st.markdown(f"<div style='text-align: center; color: blue; font-size: 20px;'>{translated_text}</div>", unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|