Spaces:
Runtime error
Runtime error
Commit
·
40b70f5
1
Parent(s):
372e060
Update pages/Chest.py
Browse files- pages/Chest.py +47 -33
pages/Chest.py
CHANGED
|
@@ -19,7 +19,8 @@ from transformers import BioGptTokenizer, BioGptForCausalLM
|
|
| 19 |
text_model = BioGptForCausalLM.from_pretrained("microsoft/biogpt")
|
| 20 |
tokenizer = BioGptTokenizer.from_pretrained("microsoft/biogpt")
|
| 21 |
labels_path = 'labels.json'
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
with open(labels_path) as json_data:
|
| 25 |
idx_to_labels = json.load(json_data)
|
|
@@ -87,7 +88,51 @@ class FineTuneModel(pl.LightningModule):
|
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
st.markdown("<h1 style='text-align: center; '>Chest Xray Diagnosis</h1>",unsafe_allow_html=True)
|
| 93 |
|
|
@@ -127,37 +172,6 @@ if uploaded_file is not None:
|
|
| 127 |
with st.spinner('Generating Text'):
|
| 128 |
generator(input_text, max_length=300, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=1)
|
| 129 |
st.markdown(generator(input_text, max_length=300, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=1)[0]['generated_text'])
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
else:
|
| 142 |
st.success("Please upload an image file ⚕️")
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
|
|
|
| 19 |
text_model = BioGptForCausalLM.from_pretrained("microsoft/biogpt")
|
| 20 |
tokenizer = BioGptTokenizer.from_pretrained("microsoft/biogpt")
|
| 21 |
labels_path = 'labels.json'
|
| 22 |
+
import os
|
| 23 |
+
import base64
|
| 24 |
|
| 25 |
with open(labels_path) as json_data:
|
| 26 |
idx_to_labels = json.load(json_data)
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
+
# Get the current working directory
|
| 92 |
+
current_dir = os.getcwd()
|
| 93 |
+
|
| 94 |
+
# Construct the absolute path to the logo.png file
|
| 95 |
+
logo_path = os.path.join(current_dir, "logo.png")
|
| 96 |
+
|
| 97 |
+
with open(logo_path, "rb") as f:
|
| 98 |
+
image_data = f.read()
|
| 99 |
+
image_base64 = base64.b64encode(image_data).decode("utf-8")
|
| 100 |
+
|
| 101 |
+
# Add custom CSS for the header
|
| 102 |
+
header_css = """
|
| 103 |
+
<style>
|
| 104 |
+
.header {
|
| 105 |
+
display: flex;
|
| 106 |
+
align-items: center;
|
| 107 |
+
justify-content: center;
|
| 108 |
+
padding: 20px;
|
| 109 |
+
font-size: 18px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.header img {
|
| 113 |
+
margin-right: 10px;
|
| 114 |
+
width: 80px;
|
| 115 |
+
height: 50px;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.header p {
|
| 119 |
+
font-size: 14px;
|
| 120 |
+
}
|
| 121 |
+
</style>
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
# Render the custom CSS
|
| 125 |
+
st.markdown(header_css, unsafe_allow_html=True)
|
| 126 |
+
|
| 127 |
+
# Render the header
|
| 128 |
+
header_html = f"""
|
| 129 |
+
<div class="header">
|
| 130 |
+
<img src='data:image/jpeg;base64,{image_base64}' alt="Logo"/>
|
| 131 |
+
<p>Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.</p>
|
| 132 |
+
</div>
|
| 133 |
+
"""
|
| 134 |
+
|
| 135 |
+
st.markdown(header_html, unsafe_allow_html=True)
|
| 136 |
|
| 137 |
st.markdown("<h1 style='text-align: center; '>Chest Xray Diagnosis</h1>",unsafe_allow_html=True)
|
| 138 |
|
|
|
|
| 172 |
with st.spinner('Generating Text'):
|
| 173 |
generator(input_text, max_length=300, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=1)
|
| 174 |
st.markdown(generator(input_text, max_length=300, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=1)[0]['generated_text'])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
else:
|
| 177 |
st.success("Please upload an image file ⚕️")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|