File size: 3,700 Bytes
c727430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d456a4
c727430
 
 
1949f12
c727430
1949f12
c727430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90cb452
c727430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import streamlit as st
from PIL import Image
import google.generativeai as genai
#from googletrans import Translator, LANGUAGES
from deep_translator import GoogleTranslator

#def translate_to_persian(text):
    # Instantiate the Translator object
#translator = Translator()

    # Translate the text
#translation = translator.translate(text, src='en', dest='fa')

    #return translation.text
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)

#st.title('Medicmate.ir')

#text_input = st.text_input('شرح حال بیمار را وارد کنید', placeholder='بیمار پسر 16 ساله که با شکایت زردی، اسهال و بی‌حالی مراجعه کرده است')

text_input2 = st.text_input('در صورتیکه نام آزمایشتان را بلدید، آنرا وارد کنید', placeholder='Liver function test (or LFT)')

#سی تی اسکن شکم-لگن با کنتراست خوراکی و وریدی'

genai.configure(api_key="AIzaSyBd36RWeqDpLur3E7TTlX3wnyIh_rdhsU8")

uploader_key = 'file_uploader'

# Function to clear the uploaded file

#def clear_file():
    #if st.session_state != None:
#    del st.session_state[uploader_key]  # This clears the file uploader widget

# Check if the delete button is pressed

# File uploader with the key
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=[]
# Display the image if available
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')
    # Translate the text to English
    g.append(txt)#text_input)
    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'):
        #st.write(res.text)
        translator = GoogleTranslator(source='en', target='fa')
        # Translate the text to Persian
        translated_text = translator.translate(l[0])
        
        # Display the translated text
        st.markdown(f"<div style='text-align: center; color: blue; font-size: 20px;'>{translated_text}</div>", unsafe_allow_html=True)

    #if st.button('Delete'):
    #    clear_file()
#uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])

#res.resolve()

# Display the uploaded image
#if uploaded_file is not None:
#    image = Image.open(uploaded_file)
#    res = mod.generate_content(["" + text_input, image], stream=True)
#    res.resolve()
#    l.append(res.text)
    #st.image(image, caption='Uploaded Image', use_column_width=True)

# Button to print "Hey you"