Spaces:
Running
Running
zy7_oldserver
commited on
Commit
·
880f41d
1
Parent(s):
66e713a
- seg2med_app/app_utils/image_utils.py +25 -3
- seg2med_app/checkinput.png +0 -0
- seg2med_app/frankenstein.jpg +0 -0
- seg2med_app/modeloutput.png +0 -0
- tutorial8_app.py +2 -18
seg2med_app/app_utils/image_utils.py
CHANGED
|
@@ -13,10 +13,32 @@ from io import BytesIO
|
|
| 13 |
default_orientation_type = 'transpose'
|
| 14 |
default_plt_origin_type = 'upper'
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
buffered = BytesIO()
|
| 18 |
-
img.
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
def processing_slice_to_right_orientation(img_slice, type=default_orientation_type):
|
| 22 |
if type == 'transpose':
|
|
|
|
| 13 |
default_orientation_type = 'transpose'
|
| 14 |
default_plt_origin_type = 'upper'
|
| 15 |
|
| 16 |
+
|
| 17 |
+
def image_to_base64(img, width=200):
|
| 18 |
buffered = BytesIO()
|
| 19 |
+
if img.mode == "RGBA":
|
| 20 |
+
img.save(buffered, format="PNG")
|
| 21 |
+
result = base64.b64encode(buffered.getvalue()).decode()
|
| 22 |
+
st.markdown(
|
| 23 |
+
f"""
|
| 24 |
+
<div style='text-align: center;'>
|
| 25 |
+
<img src="data:image/png;base64,{result}" width="{width}">
|
| 26 |
+
</div>
|
| 27 |
+
""",
|
| 28 |
+
unsafe_allow_html=True
|
| 29 |
+
)
|
| 30 |
+
else:
|
| 31 |
+
img.save(buffered, format="JPEG")
|
| 32 |
+
result = base64.b64encode(buffered.getvalue()).decode()
|
| 33 |
+
st.markdown(
|
| 34 |
+
f"""
|
| 35 |
+
<div style='text-align: center;'>
|
| 36 |
+
<img src="data:image/jpeg;base64,{result}" width="{width}">
|
| 37 |
+
</div>
|
| 38 |
+
""",
|
| 39 |
+
unsafe_allow_html=True
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
|
| 43 |
def processing_slice_to_right_orientation(img_slice, type=default_orientation_type):
|
| 44 |
if type == 'transpose':
|
seg2med_app/checkinput.png
CHANGED
|
|
seg2med_app/frankenstein.jpg
DELETED
|
Binary file (28.4 kB)
|
|
|
seg2med_app/modeloutput.png
CHANGED
|
|
tutorial8_app.py
CHANGED
|
@@ -66,24 +66,8 @@ def reset_app():
|
|
| 66 |
print("App has been reset. Login information is preserved.")
|
| 67 |
st._rerun()
|
| 68 |
|
| 69 |
-
image = Image.open(os.path.join(app_root, "
|
| 70 |
-
|
| 71 |
-
f"""
|
| 72 |
-
<div style='text-align: center;'>
|
| 73 |
-
<img src="data:image/jpeg;base64,{image_to_base64(image)}" width="150">
|
| 74 |
-
</div>
|
| 75 |
-
""",
|
| 76 |
-
unsafe_allow_html=True
|
| 77 |
-
)
|
| 78 |
-
# copyright for logo
|
| 79 |
-
st.markdown(
|
| 80 |
-
"""
|
| 81 |
-
<p style="font-size:10px; color:gray; text-align: right;">
|
| 82 |
-
Logo Frankenstein – Designed by <a href="https://www.freepik.com" target="_blank" style="color:gray;">Freepik</a>
|
| 83 |
-
</p>
|
| 84 |
-
""",
|
| 85 |
-
unsafe_allow_html=True
|
| 86 |
-
)
|
| 87 |
|
| 88 |
|
| 89 |
st.title("\U0001F9E0 Frankenstein - multimodal medical image generation")
|
|
|
|
| 66 |
print("App has been reset. Login information is preserved.")
|
| 67 |
st._rerun()
|
| 68 |
|
| 69 |
+
image = Image.open(os.path.join(app_root, "Frankenstein0.png"))
|
| 70 |
+
image_to_base64(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
|
| 73 |
st.title("\U0001F9E0 Frankenstein - multimodal medical image generation")
|