Update pages/Life_cycle_of_ML.py
Browse files- pages/Life_cycle_of_ML.py +12 -1
pages/Life_cycle_of_ML.py
CHANGED
|
@@ -650,6 +650,10 @@ def table():
|
|
| 650 |
In this step, we load the uploaded image using OpenCV. The image is first read as raw bytes,
|
| 651 |
which are then decoded into an image using OpenCV's `cv2.imdecode()` function.
|
| 652 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
|
| 654 |
# Load the image
|
| 655 |
image_array = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
|
@@ -666,6 +670,8 @@ def table():
|
|
| 666 |
Grayscale images have a single channel, making them simpler to process.
|
| 667 |
""")
|
| 668 |
|
|
|
|
|
|
|
| 669 |
# Convert to grayscale
|
| 670 |
processed_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 671 |
|
|
@@ -692,6 +698,8 @@ def table():
|
|
| 692 |
Resizing the image reduces the number of pixels, making it easier to process in further steps.
|
| 693 |
""")
|
| 694 |
|
|
|
|
|
|
|
| 695 |
# Resize the image
|
| 696 |
resized_image = cv2.resize(processed_image, (100, 100))
|
| 697 |
|
|
@@ -707,7 +715,8 @@ def table():
|
|
| 707 |
After resizing the image, we flatten it into a 1D array. This process involves converting the
|
| 708 |
2D matrix (and channels if color) of pixels into a single row of values, which can be used for further analysis or modeling.
|
| 709 |
""")
|
| 710 |
-
|
|
|
|
| 711 |
# Flatten the resized image
|
| 712 |
flattened_image = resized_image.flatten()
|
| 713 |
|
|
@@ -718,6 +727,8 @@ def table():
|
|
| 718 |
with the pixel data in a tabular format, which is useful for further data analysis, machine learning, etc.
|
| 719 |
""")
|
| 720 |
|
|
|
|
|
|
|
| 721 |
# Create a DataFrame for the flattened image
|
| 722 |
image_data = pd.DataFrame(flattened_image.reshape(1, -1))
|
| 723 |
|
|
|
|
| 650 |
In this step, we load the uploaded image using OpenCV. The image is first read as raw bytes,
|
| 651 |
which are then decoded into an image using OpenCV's `cv2.imdecode()` function.
|
| 652 |
""")
|
| 653 |
+
st.code("""
|
| 654 |
+
## Load the image
|
| 655 |
+
image_array = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
| 656 |
+
image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)""" ), language="python")
|
| 657 |
|
| 658 |
# Load the image
|
| 659 |
image_array = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
|
|
|
| 670 |
Grayscale images have a single channel, making them simpler to process.
|
| 671 |
""")
|
| 672 |
|
| 673 |
+
st.code("""cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)""",language="python")
|
| 674 |
+
|
| 675 |
# Convert to grayscale
|
| 676 |
processed_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 677 |
|
|
|
|
| 698 |
Resizing the image reduces the number of pixels, making it easier to process in further steps.
|
| 699 |
""")
|
| 700 |
|
| 701 |
+
st.code("""## Resize the image
|
| 702 |
+
cv2.resize(processed_image, (100, 100))""",language="python")
|
| 703 |
# Resize the image
|
| 704 |
resized_image = cv2.resize(processed_image, (100, 100))
|
| 705 |
|
|
|
|
| 715 |
After resizing the image, we flatten it into a 1D array. This process involves converting the
|
| 716 |
2D matrix (and channels if color) of pixels into a single row of values, which can be used for further analysis or modeling.
|
| 717 |
""")
|
| 718 |
+
st.code("""# Flatten
|
| 719 |
+
resized_image.flatten()""",language="python")
|
| 720 |
# Flatten the resized image
|
| 721 |
flattened_image = resized_image.flatten()
|
| 722 |
|
|
|
|
| 727 |
with the pixel data in a tabular format, which is useful for further data analysis, machine learning, etc.
|
| 728 |
""")
|
| 729 |
|
| 730 |
+
st.code("""# DataFrame
|
| 731 |
+
pd.DataFrame(flattened_image.reshape(1, -1))""",language="python")
|
| 732 |
# Create a DataFrame for the flattened image
|
| 733 |
image_data = pd.DataFrame(flattened_image.reshape(1, -1))
|
| 734 |
|