Update pages/3_Life Cycle Of ML Project.py
Browse files
pages/3_Life Cycle Of ML Project.py
CHANGED
|
@@ -470,9 +470,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 470 |
|
| 471 |
elif st.session_state.page == "Video_capture_and_explanation_page":
|
| 472 |
|
| 473 |
-
|
| 474 |
|
| 475 |
-
|
| 476 |
**Purpose**: Captures live video from a webcam or reads a video file using OpenCV.
|
| 477 |
### Syntax
|
| 478 |
```python
|
|
@@ -516,8 +516,8 @@ elif st.session_state.page == "Video_capture_and_explanation_page":
|
|
| 516 |
|
| 517 |
##----------##
|
| 518 |
|
| 519 |
-
|
| 520 |
-
|
| 521 |
Purpose:
|
| 522 |
cv2.waitKey() is a key function used to handle keyboard events in OpenCV. It is commonly used to display images or video frames and wait for a user input.
|
| 523 |
Syntax:
|
|
@@ -570,7 +570,7 @@ elif st.session_state.page == "Video_capture_and_explanation_page":
|
|
| 570 |
|
| 571 |
###------KEY POINTS -----###
|
| 572 |
|
| 573 |
-
|
| 574 |
1. **Video Capture (`cv2.VideoCapture`)**: Opens and reads video either from the webcam or from a video file.
|
| 575 |
- **Method `cap.read()`**: Captures individual frames from the video source.
|
| 576 |
- **Releasing the capture (`cap.release()`)**: Ensures that the resources are freed once done.
|
|
@@ -604,10 +604,10 @@ This explanation provides both the purpose and practical use cases of `cv2.Video
|
|
| 604 |
|
| 605 |
elif st.session_state.page == "affine_transformation_matrix":
|
| 606 |
# Header for Affine Transformation Matrix
|
| 607 |
-
|
| 608 |
|
| 609 |
# Description of Affine Transformation
|
| 610 |
-
|
| 611 |
An **Affine Transformation** is a linear mapping method that preserves points, straight lines, and planes. In other words, it maintains the structure of the original object while allowing for operations like translation, scaling, rotation, reflection, and shearing. Affine transformations are widely used in computer graphics, computer vision, image processing, and geometry.
|
| 612 |
Affine transformations can be represented by a **transformation matrix** of the following form:
|
| 613 |
\\[
|
|
@@ -627,9 +627,9 @@ elif st.session_state.page == "affine_transformation_matrix":
|
|
| 627 |
""")
|
| 628 |
|
| 629 |
# Key Points Section
|
| 630 |
-
|
| 631 |
|
| 632 |
-
|
| 633 |
### 1. **Preserves Collinearity**
|
| 634 |
- Points that lie on a straight line before transformation remain on a straight line after transformation.
|
| 635 |
### 2. **Preserves Ratios of Distances**
|
|
@@ -670,8 +670,8 @@ elif st.session_state.page == "affine_transformation_matrix":
|
|
| 670 |
|
| 671 |
# ----------------- Semi-Structured Data Page -----------------
|
| 672 |
elif st.session_state.page == "semi_structured_data":
|
| 673 |
-
|
| 674 |
-
|
| 675 |
Semi-structured data does not have a rigid structure but contains tags and markers to separate different data elements, like XML or JSON.
|
| 676 |
""")
|
| 677 |
|
|
@@ -693,27 +693,27 @@ elif st.session_state.page == "semi_structured_data":
|
|
| 693 |
|
| 694 |
# ----------------- CSV Data Page -----------------
|
| 695 |
elif st.session_state.page == "csv":
|
| 696 |
-
|
| 697 |
-
|
| 698 |
CSV (Comma-Separated Values) is a simple format used to store tabular data. Each line in the file represents a row, and commas separate the values within the row.
|
| 699 |
""")
|
| 700 |
-
|
| 701 |
-
|
| 702 |
import pandas as pd
|
| 703 |
# Read a CSV file
|
| 704 |
df = pd.read_csv('data.csv')
|
| 705 |
print(df)
|
| 706 |
""", language='python')
|
| 707 |
|
| 708 |
-
|
| 709 |
-
|
| 710 |
- *File not found*: Incorrect file path.
|
| 711 |
- *Wrong delimiter*: The CSV uses a different delimiter (e.g., semicolon).
|
| 712 |
- *Missing Libraries*: pandas might be missing.
|
| 713 |
""")
|
| 714 |
|
| 715 |
-
|
| 716 |
-
|
| 717 |
# Install required libraries
|
| 718 |
# pip install pandas
|
| 719 |
# Handle file not found
|
|
@@ -724,7 +724,7 @@ except FileNotFoundError:
|
|
| 724 |
# Handle incorrect delimiter
|
| 725 |
df = pd.read_csv('data.csv', delimiter=';')
|
| 726 |
""", language='python')
|
| 727 |
-
|
| 728 |
|
| 729 |
|
| 730 |
if st.button(":red[Back to Structured Data]"):
|
|
@@ -787,13 +787,13 @@ with open('data.json', 'r') as file:
|
|
| 787 |
print(data)
|
| 788 |
""", language='python')
|
| 789 |
|
| 790 |
-
|
| 791 |
-
|
| 792 |
- *File not found*: Incorrect file path.
|
| 793 |
""")
|
| 794 |
|
| 795 |
-
|
| 796 |
-
|
| 797 |
try:
|
| 798 |
with open('data.json', 'r') as file:
|
| 799 |
data = json.load(file)
|
|
@@ -813,8 +813,8 @@ elif st.session_state.page == "html":
|
|
| 813 |
HTML (HyperText Markup Language) is the standard language for creating webpages. It uses a markup structure to format text, images, and other content on the web.
|
| 814 |
""")
|
| 815 |
|
| 816 |
-
|
| 817 |
-
|
| 818 |
import pandas as pd
|
| 819 |
|
| 820 |
# Reading HTML data
|
|
@@ -822,14 +822,14 @@ dfs = pd.read_html('sample.html')
|
|
| 822 |
print(dfs[0]) # Display the first table from the HTML file
|
| 823 |
""", language='python')
|
| 824 |
|
| 825 |
-
|
| 826 |
-
|
| 827 |
- *File not found*: Incorrect file path.
|
| 828 |
- *Missing Libraries*: pandas might be missing.
|
| 829 |
""")
|
| 830 |
|
| 831 |
-
|
| 832 |
-
|
| 833 |
# Install required libraries
|
| 834 |
# pip install pandas
|
| 835 |
# Handle file not found
|
|
|
|
| 470 |
|
| 471 |
elif st.session_state.page == "Video_capture_and_explanation_page":
|
| 472 |
|
| 473 |
+
st.header("🎥 Video Capture with `cv2.VideoCapture()`")
|
| 474 |
|
| 475 |
+
st.markdown("""
|
| 476 |
**Purpose**: Captures live video from a webcam or reads a video file using OpenCV.
|
| 477 |
### Syntax
|
| 478 |
```python
|
|
|
|
| 516 |
|
| 517 |
##----------##
|
| 518 |
|
| 519 |
+
st.header("⏱️ cv2.waitKey() for Key Event Handling")
|
| 520 |
+
st.markdown("""
|
| 521 |
Purpose:
|
| 522 |
cv2.waitKey() is a key function used to handle keyboard events in OpenCV. It is commonly used to display images or video frames and wait for a user input.
|
| 523 |
Syntax:
|
|
|
|
| 570 |
|
| 571 |
###------KEY POINTS -----###
|
| 572 |
|
| 573 |
+
st.markdown("""
|
| 574 |
1. **Video Capture (`cv2.VideoCapture`)**: Opens and reads video either from the webcam or from a video file.
|
| 575 |
- **Method `cap.read()`**: Captures individual frames from the video source.
|
| 576 |
- **Releasing the capture (`cap.release()`)**: Ensures that the resources are freed once done.
|
|
|
|
| 604 |
|
| 605 |
elif st.session_state.page == "affine_transformation_matrix":
|
| 606 |
# Header for Affine Transformation Matrix
|
| 607 |
+
st.header("Affine Transformation Matrix")
|
| 608 |
|
| 609 |
# Description of Affine Transformation
|
| 610 |
+
st.markdown("""
|
| 611 |
An **Affine Transformation** is a linear mapping method that preserves points, straight lines, and planes. In other words, it maintains the structure of the original object while allowing for operations like translation, scaling, rotation, reflection, and shearing. Affine transformations are widely used in computer graphics, computer vision, image processing, and geometry.
|
| 612 |
Affine transformations can be represented by a **transformation matrix** of the following form:
|
| 613 |
\\[
|
|
|
|
| 627 |
""")
|
| 628 |
|
| 629 |
# Key Points Section
|
| 630 |
+
st.header("Key Points of Affine Transformations")
|
| 631 |
|
| 632 |
+
st.markdown("""
|
| 633 |
### 1. **Preserves Collinearity**
|
| 634 |
- Points that lie on a straight line before transformation remain on a straight line after transformation.
|
| 635 |
### 2. **Preserves Ratios of Distances**
|
|
|
|
| 670 |
|
| 671 |
# ----------------- Semi-Structured Data Page -----------------
|
| 672 |
elif st.session_state.page == "semi_structured_data":
|
| 673 |
+
st.title(":blue[Semi-Structured Data]")
|
| 674 |
+
st.markdown("""
|
| 675 |
Semi-structured data does not have a rigid structure but contains tags and markers to separate different data elements, like XML or JSON.
|
| 676 |
""")
|
| 677 |
|
|
|
|
| 693 |
|
| 694 |
# ----------------- CSV Data Page -----------------
|
| 695 |
elif st.session_state.page == "csv":
|
| 696 |
+
st.title(":red[CSV Data Format]")
|
| 697 |
+
st.markdown("""
|
| 698 |
CSV (Comma-Separated Values) is a simple format used to store tabular data. Each line in the file represents a row, and commas separate the values within the row.
|
| 699 |
""")
|
| 700 |
+
st.markdown("### How to Read a CSV file")
|
| 701 |
+
st.code("""
|
| 702 |
import pandas as pd
|
| 703 |
# Read a CSV file
|
| 704 |
df = pd.read_csv('data.csv')
|
| 705 |
print(df)
|
| 706 |
""", language='python')
|
| 707 |
|
| 708 |
+
st.markdown("### Issues Encountered")
|
| 709 |
+
st.write("""
|
| 710 |
- *File not found*: Incorrect file path.
|
| 711 |
- *Wrong delimiter*: The CSV uses a different delimiter (e.g., semicolon).
|
| 712 |
- *Missing Libraries*: pandas might be missing.
|
| 713 |
""")
|
| 714 |
|
| 715 |
+
st.write("### Solutions")
|
| 716 |
+
st.code("""
|
| 717 |
# Install required libraries
|
| 718 |
# pip install pandas
|
| 719 |
# Handle file not found
|
|
|
|
| 724 |
# Handle incorrect delimiter
|
| 725 |
df = pd.read_csv('data.csv', delimiter=';')
|
| 726 |
""", language='python')
|
| 727 |
+
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/10MHcHTn40RcRA80TMvyXLiIwmU94Nt4N?usp=sharing")
|
| 728 |
|
| 729 |
|
| 730 |
if st.button(":red[Back to Structured Data]"):
|
|
|
|
| 787 |
print(data)
|
| 788 |
""", language='python')
|
| 789 |
|
| 790 |
+
st.write("### Issues Encountered")
|
| 791 |
+
st.write("""
|
| 792 |
- *File not found*: Incorrect file path.
|
| 793 |
""")
|
| 794 |
|
| 795 |
+
st.write("### Solutions to These Issues")
|
| 796 |
+
st.code("""
|
| 797 |
try:
|
| 798 |
with open('data.json', 'r') as file:
|
| 799 |
data = json.load(file)
|
|
|
|
| 813 |
HTML (HyperText Markup Language) is the standard language for creating webpages. It uses a markup structure to format text, images, and other content on the web.
|
| 814 |
""")
|
| 815 |
|
| 816 |
+
st.markdown("### Example: Reading HTML data")
|
| 817 |
+
st.code("""
|
| 818 |
import pandas as pd
|
| 819 |
|
| 820 |
# Reading HTML data
|
|
|
|
| 822 |
print(dfs[0]) # Display the first table from the HTML file
|
| 823 |
""", language='python')
|
| 824 |
|
| 825 |
+
st.write("### Issues Encountered")
|
| 826 |
+
st.write("""
|
| 827 |
- *File not found*: Incorrect file path.
|
| 828 |
- *Missing Libraries*: pandas might be missing.
|
| 829 |
""")
|
| 830 |
|
| 831 |
+
st.write("### Solutions to These Issues")
|
| 832 |
+
st.code("""
|
| 833 |
# Install required libraries
|
| 834 |
# pip install pandas
|
| 835 |
# Handle file not found
|