Spaces:
Sleeping
Sleeping
Update pages/1_Introduction.py
Browse files- pages/1_Introduction.py +13 -4
pages/1_Introduction.py
CHANGED
|
@@ -3,13 +3,21 @@ from PIL import Image
|
|
| 3 |
import base64
|
| 4 |
import io
|
| 5 |
|
| 6 |
-
# Base64 encoded image string
|
| 7 |
encoded_image = "UklGRrICBgBXRUJQVlA4IKrbBABQ9xCdASoABwAEPjEWiUOiISUmJZYbuMAGCWNsiXpgHwljA+sbSoKb/m/ZfJS/8fokeQ9+Mnxx"
|
| 8 |
|
| 9 |
# Decode Base64 string to image
|
| 10 |
def decode_base64_image(encoded_str):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Title and introduction
|
| 14 |
st.title('Understanding Machine Learning: Teaching Machines Like Children')
|
| 15 |
|
|
@@ -21,7 +29,8 @@ In this app, we'll use the analogy of a father teaching his child to explain the
|
|
| 21 |
|
| 22 |
# Display the image
|
| 23 |
image = decode_base64_image(encoded_image)
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
# Supervised Learning Explanation
|
| 27 |
st.header('Supervised Learning')
|
|
|
|
| 3 |
import base64
|
| 4 |
import io
|
| 5 |
|
| 6 |
+
# Base64 encoded image string (ensure the base64 string is complete)
|
| 7 |
encoded_image = "UklGRrICBgBXRUJQVlA4IKrbBABQ9xCdASoABwAEPjEWiUOiISUmJZYbuMAGCWNsiXpgHwljA+sbSoKb/m/ZfJS/8fokeQ9+Mnxx"
|
| 8 |
|
| 9 |
# Decode Base64 string to image
|
| 10 |
def decode_base64_image(encoded_str):
|
| 11 |
+
try:
|
| 12 |
+
# Decode the base64 string
|
| 13 |
+
img_data = base64.b64decode(encoded_str)
|
| 14 |
+
# Return the image object
|
| 15 |
+
return Image.open(io.BytesIO(img_data))
|
| 16 |
+
except Exception as e:
|
| 17 |
+
# Handle any errors during decoding and show error message
|
| 18 |
+
st.error(f"Error decoding image: {e}")
|
| 19 |
+
return None
|
| 20 |
+
|
| 21 |
# Title and introduction
|
| 22 |
st.title('Understanding Machine Learning: Teaching Machines Like Children')
|
| 23 |
|
|
|
|
| 29 |
|
| 30 |
# Display the image
|
| 31 |
image = decode_base64_image(encoded_image)
|
| 32 |
+
if image:
|
| 33 |
+
st.image(image, caption='A father teaching his child by showing dog and cat pictures')
|
| 34 |
|
| 35 |
# Supervised Learning Explanation
|
| 36 |
st.header('Supervised Learning')
|