Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
5d3655e
1
Parent(s):
5a203eb
Update app.py
Browse files
app.py
CHANGED
@@ -173,10 +173,31 @@ def view_database():
|
|
173 |
c.execute("SELECT name, age, medical_record, sex, input_image, predicted_image, result FROM results")
|
174 |
rows = c.fetchall()
|
175 |
conn.close()
|
176 |
-
|
177 |
-
#
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
return df
|
181 |
|
182 |
# Function to download database or image
|
|
|
173 |
c.execute("SELECT name, age, medical_record, sex, input_image, predicted_image, result FROM results")
|
174 |
rows = c.fetchall()
|
175 |
conn.close()
|
176 |
+
|
177 |
+
# Prepare the data for display
|
178 |
+
data = []
|
179 |
+
for row in rows:
|
180 |
+
name, age, medical_record, sex, input_image_bytes, predicted_image_bytes, result = row
|
181 |
+
|
182 |
+
# Decode the images
|
183 |
+
input_image = Image.open(BytesIO(input_image_bytes))
|
184 |
+
predicted_image = Image.open(BytesIO(predicted_image_bytes))
|
185 |
+
|
186 |
+
# Convert images to base64 for display
|
187 |
+
buffered_input = BytesIO()
|
188 |
+
input_image.save(buffered_input, format="PNG")
|
189 |
+
input_image_base64 = base64.b64encode(buffered_input.getvalue()).decode('utf-8')
|
190 |
+
|
191 |
+
buffered_predicted = BytesIO()
|
192 |
+
predicted_image.save(buffered_predicted, format="PNG")
|
193 |
+
predicted_image_base64 = base64.b64encode(buffered_predicted.getvalue()).decode('utf-8')
|
194 |
+
|
195 |
+
# Append to data
|
196 |
+
data.append([name, age, medical_record, sex, input_image_base64, predicted_image_base64, result])
|
197 |
+
|
198 |
+
# Create a DataFrame
|
199 |
+
df = pd.DataFrame(data, columns=["Name", "Age", "Medical Record", "Sex", "Input Image", "Predicted Image", "Result"])
|
200 |
+
|
201 |
return df
|
202 |
|
203 |
# Function to download database or image
|