Spaces:
Runtime error
Runtime error
File size: 5,599 Bytes
e1e411c 24ad10b e1e411c 9d1d440 e1e411c 24ad10b 45bfcea e1e411c 24ad10b e1e411c |
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
import streamlit as st
import requests
# API processing function
def analyze_blood_test(file, username, password, language='English'):
url = 'https://app.aibloodtestinterpret.com/api/analyze'
files = {'file': (file.name, file, 'multipart/form-data')}
data = {'username': username, 'password': password, 'language': language}
response = requests.post(url, files=files, data=data)
return response
# Main function for the Streamlit app
def main():
# Custom CSS styling for the app
st.markdown(
"""
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
color: #343a40;
}
.main {
background-color: #ffffff;
padding: 2rem;
border-radius: 0.5rem;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}
h1 {
color: #007bff;
font-size: 2.5rem;
text-align: center;
margin-bottom: 2rem;
}
h2, h3, h4 {
color: #0056b3;
}
.sidebar .sidebar-content {
background-color: #e9ecef;
padding: 2rem;
border-radius: 0.5rem;
}
.stButton>button {
background-color: #007bff;
color: white;
border-radius: 0.25rem;
padding: 0.75rem 1.5rem;
font-size: 1rem;
cursor: pointer;
}
.stButton>button:hover {
background-color: #0056b3;
}
.stDownloadButton>button {
background-color: #28a745;
color: white;
border-radius: 0.25rem;
padding: 0.75rem 1.5rem;
font-size: 1rem;
cursor: pointer;
}
.stDownloadButton>button:hover {
background-color: #218838;
}
</style>
""",
unsafe_allow_html=True
)
# App main content
st.markdown(
"""
<div style="text-align: center; margin-bottom: 40px;">
<img src="https://lh5.googleusercontent.com/acxDsEgG6qumlBmHKsNK1j8kxa4Z4Tsq1QBLBBydVKMGOyH3Qn1JU5AklbDis3SlVO_mY7KSVPnkzhul_5Zxr_023IU_UY0cxVG-VhY1nTj7A-ritWtDEAswMCo0jVMkdw=w2560" alt="AI Blood Test Interpretation Logo" width="300">
</div>
""",
unsafe_allow_html=True
)
st.sidebar.title('About')
st.sidebar.info('''\
### Free Trial Available
Take advantage of our limited-time free trial for all humanity.
''')
st.sidebar.info('''\
### Product Release
After 1.5 years of diligent effort, the AI Blood Test Interpretation tool is now officially launched.
''')
st.sidebar.info('''\
### AI Inventor Contact
For any inquiries, please contact: [email protected]
''')
st.write('Welcome to the AI-driven Blood Test Interpreter. Upload your blood test file and get a detailed analysis within seconds.')
uploaded_file = st.file_uploader('Upload your blood test image or PDF', type=['jpg', 'jpeg', 'png', 'pdf'])
username = st.text_input('Username', value='demo')
password = st.text_input('Password', value='demo', type='password')
languages = [
'English', 'Spanish', 'French', 'German', 'Italian', 'Portuguese', 'Dutch',
'Japanese', 'Chinese', 'Korean', 'Russian', 'Arabic', 'Hindi', 'Bengali',
'Turkish', 'Swedish', 'Norwegian', 'Danish', 'Finnish', 'Greek', 'Hebrew',
'Polish', 'Czech', 'Hungarian', 'Romanian', 'Bulgarian', 'Serbian', 'Croatian',
'Slovak', 'Slovenian', 'Ukrainian', 'Belarusian', 'Latvian', 'Lithuanian',
'Estonian', 'Macedonian', 'Albanian', 'Bosnian', 'Irish', 'Maltese',
'Icelandic', 'Welsh', 'Galician', 'Basque', 'Catalan', 'Afrikaans',
'Swahili', 'Zulu', 'Xhosa', 'Amharic', 'Yoruba', 'Igbo', 'Somali',
'Vietnamese', 'Thai', 'Filipino', 'Malay', 'Indonesian', 'Mongolian',
'Khmer', 'Sinhala', 'Burmese', 'Lao', 'Marathi', 'Gujarati', 'Punjabi',
'Tamil', 'Telugu', 'Kannada', 'Malayalam', 'Oriya', 'Assamese',
'Nepali', 'Pashto', 'Farsi', 'Urdu', 'Kurdish', 'Uzbek', 'Kazakh',
'Tajik', 'Turkmen', 'Kyrgyz', 'Azerbaijani', 'Armenian', 'Georgian',
'Haitian Creole', 'Javanese', 'Sundanese', 'Madurese', 'Minangkabau',
'Acehnese', 'Balinese', 'Batak', 'Buginese', 'Rejang', 'Sasak'
]
language = st.selectbox('Report Language', languages)
# Analyze button
if st.button('Analyze'):
if uploaded_file and username and password:
response = analyze_blood_test(uploaded_file, username, password, language)
if response.status_code == 200:
st.success('Analysis completed successfully')
pdf_filename = f"{uploaded_file.name.split('.')[0]}_results.pdf"
with open(pdf_filename, 'wb') as pdf_file:
pdf_file.write(response.content)
with open(pdf_filename, 'rb') as pdf_file:
st.download_button('Download PDF Report', data=pdf_file, file_name=pdf_filename)
else:
st.error(f"Failed to analyze file. Status code: {response.status_code}, Message: {response.json()}")
else:
st.warning('Please fill in all fields and upload a file.')
if __name__ == '__main__':
main() |