DOMMETI commited on
Commit
f25166c
·
verified ·
1 Parent(s): 8eff98c

Update pages/7_Un_Structured_Data.py

Browse files
Files changed (1) hide show
  1. pages/7_Un_Structured_Data.py +156 -81
pages/7_Un_Structured_Data.py CHANGED
@@ -1,8 +1,12 @@
1
  import streamlit as st
2
  from PIL import Image
3
- import os
 
 
 
 
4
 
5
- # Apply styling
6
  st.markdown("""
7
  <style>
8
  body {
@@ -11,108 +15,179 @@ st.markdown("""
11
  h1 {
12
  color: #00FFFF;
13
  font-family: 'Roboto', sans-serif;
14
- font-weight: 700;
15
  text-align: center;
16
  margin-bottom: 25px;
17
  }
18
  h2 {
19
  color: #FFFACD;
20
  font-family: 'Roboto', sans-serif;
21
- font-weight: 600;
22
  margin-top: 30px;
23
  }
24
  h3 {
25
  color: #ba95b0;
26
  font-family: 'Roboto', sans-serif;
27
- font-weight: 500;
28
  margin-top: 20px;
29
  }
30
  p {
31
  font-family: 'Georgia', serif;
32
  line-height: 1.8;
33
- color: #495057;
34
  margin-bottom: 20px;
35
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </style>
37
- """, unsafe_allow_html=True)
38
-
39
- # Define function to display unstructured data page
40
- def unstructured_data_page():
41
- st.title("📂 Unstructured Data")
42
- st.markdown("""
43
- **Unstructured data** refers to information that does not follow a predefined model, such as text, images, videos, and social media posts. It often requires advanced tools like AI and machine learning to process effectively.
44
- """)
45
- st.image("https://via.placeholder.com/800x400?text=Unstructured+Data", caption="Examples of Unstructured Data")
46
-
47
- st.header("Types of Unstructured Data")
48
- col1, col2 = st.columns(2)
49
- with col1:
50
- if st.button("🖼️ Images"):
51
- st.session_state.page = "image"
52
- with col2:
53
- if st.button("🎥 Videos"):
54
- st.session_state.page = "video"
55
-
56
- # Define function for image page
57
- def image_page():
58
- st.title("🖼️ Image Data")
59
- st.markdown("""
60
- Images consist of pixels, which store information such as color and intensity. Images can be stored in formats like JPEG, PNG, and BMP.
61
- """)
62
- st.image("https://via.placeholder.com/600x300?text=Image+Grid", caption="Image Grid Representation", use_column_width=True)
63
-
64
- st.header("📏 Image Formats and Resolution")
65
- st.markdown("""
66
- - **JPEG/JPG**: Compressed format for photos.
67
- - **PNG**: Supports transparency.
68
- - **GIF**: Used for animations.
69
- - **BMP**: Raw image data.
70
- """)
71
- st.image("https://via.placeholder.com/600x300?text=Resolution+Comparison", caption="Resolution Comparison", use_column_width=True)
72
-
73
- st.subheader("Upload Your Image")
74
- uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
75
- if uploaded_file:
76
- img = Image.open(uploaded_file)
77
- st.image(img, caption="Uploaded Image", use_column_width=True)
78
-
79
- if st.button("🔙 Back to Unstructured Data"):
80
- st.session_state.page = "unstructured_data"
81
-
82
- # Define function for video page
83
- def video_page():
84
- st.title("🎥 Video Data")
85
- st.markdown("""
86
- Videos are sequences of frames (images) processed continuously. OpenCV provides tools for video processing.
87
- """)
88
-
89
- st.header("📹 Example: Video Capture")
90
- st.code("""
 
 
 
 
 
 
 
 
91
  import cv2
92
- cap = cv2.VideoCapture(0)
 
 
93
  while True:
94
- ret, frame = cap.read()
95
  if not ret:
96
  break
97
- cv2.imshow('Webcam Feed', frame)
 
98
  if cv2.waitKey(1) & 0xFF == ord('q'):
99
  break
100
- cap.release()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  cv2.destroyAllWindows()
102
- """, language="python")
103
- st.image("https://via.placeholder.com/600x300?text=Video+Processing", caption="Video Processing Example", use_column_width=True)
104
-
105
- if st.button("🔙 Back to Unstructured Data"):
106
- st.session_state.page = "unstructured_data"
107
-
108
- # Initialize session state
109
- if "page" not in st.session_state:
110
- st.session_state.page = "unstructured_data"
111
-
112
- # Page routing logic
113
- if st.session_state.page == "unstructured_data":
114
- unstructured_data_page()
115
- elif st.session_state.page == "image":
116
- image_page()
117
- elif st.session_state.page == "video":
118
- video_page()
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from PIL import Image
3
+ import cv2
4
+ import numpy as np
5
+
6
+ # Page Configuration
7
+ st.set_page_config(page_title="Unstructured Data Exploration", layout="wide")
8
 
9
+ # Custom CSS Styling
10
  st.markdown("""
11
  <style>
12
  body {
 
15
  h1 {
16
  color: #00FFFF;
17
  font-family: 'Roboto', sans-serif;
18
+ font-weight: bold;
19
  text-align: center;
20
  margin-bottom: 25px;
21
  }
22
  h2 {
23
  color: #FFFACD;
24
  font-family: 'Roboto', sans-serif;
25
+ font-weight: 700;
26
  margin-top: 30px;
27
  }
28
  h3 {
29
  color: #ba95b0;
30
  font-family: 'Roboto', sans-serif;
31
+ font-weight: 600;
32
  margin-top: 20px;
33
  }
34
  p {
35
  font-family: 'Georgia', serif;
36
  line-height: 1.8;
37
+ color: #2b2b2b;
38
  margin-bottom: 20px;
39
  }
40
+ .icon-bullet {
41
+ list-style-type: none;
42
+ padding-left: 20px;
43
+ }
44
+ .icon-bullet li {
45
+ font-family: 'Georgia', serif;
46
+ font-size: 1.1em;
47
+ margin-bottom: 10px;
48
+ color: #2b2b2b;
49
+ }
50
+ .icon-bullet li::before {
51
+ content: "✔️";
52
+ padding-right: 10px;
53
+ color: #00FFFF;
54
+ }
55
  </style>
56
+ """, unsafe_allow_html=True)
57
+
58
+ # Page Title
59
+ st.title("Unstructured Data Exploration")
60
+
61
+ # Section 1: Introduction
62
+ st.header("What is Unstructured Data?")
63
+ st.write("""
64
+ Unstructured data refers to information that lacks a predefined data model or is not organized in a standard manner. It encompasses:
65
+ - Text data (emails, social media posts)
66
+ - Image data (photos, medical scans)
67
+ - Audio and video content
68
+ """)
69
+
70
+ st.image("https://via.placeholder.com/800x400", caption="Examples of Unstructured Data", use_column_width=True)
71
+
72
+ # Section 2: Characteristics
73
+ st.header("Characteristics of Unstructured Data")
74
+ st.markdown("""
75
+ <ul class="icon-bullet">
76
+ <li>Does not conform to relational database models.</li>
77
+ <li>Requires advanced tools like AI and machine learning for analysis.</li>
78
+ <li>Includes multimedia and textual formats.</li>
79
+ </ul>
80
+ """, unsafe_allow_html=True)
81
+
82
+ # Section 3: Image Data
83
+ st.header("Image Data")
84
+ st.write("""
85
+ Images are a significant part of unstructured data. They are represented as a grid of pixels, each containing information about color and intensity.
86
+ """)
87
+ st.image("https://via.placeholder.com/400x250", caption="Image Grid and Pixels", use_column_width=True)
88
+
89
+ st.subheader("Common Image Formats")
90
+ st.markdown("""
91
+ <ul class="icon-bullet">
92
+ <li>**JPEG**: Ideal for compressed images.</li>
93
+ <li>**PNG**: Supports transparency.</li>
94
+ <li>**GIF**: Used for animations.</li>
95
+ <li>**BMP**: Bitmap format for uncompressed images.</li>
96
+ </ul>
97
+ """, unsafe_allow_html=True)
98
+
99
+ # Subsection: Color Spaces
100
+ st.subheader("Color Spaces")
101
+ st.write("""
102
+ Color spaces define how color information is represented in an image. Popular color spaces include:
103
+ - **RGB**: Red, Green, and Blue channels.
104
+ - **Grayscale**: Shades of gray from black to white.
105
+ - **Black & White**: Binary representation (0 for black, 1 for white).
106
+ """)
107
+ st.image("https://via.placeholder.com/400x250", caption="Color Space Examples", use_column_width=True)
108
+
109
+ # Section 4: Video Data
110
+ st.header("Video Data")
111
+ st.write("""
112
+ Videos are essentially sequences of images (frames) displayed in rapid succession. They are commonly used in surveillance, entertainment, and training systems.
113
+ """)
114
+ st.image("https://via.placeholder.com/400x250", caption="Video Frames", use_column_width=True)
115
+
116
+ st.subheader("Video Processing with OpenCV")
117
+ st.code("""
118
  import cv2
119
+
120
+ # Open a video file
121
+ video = cv2.VideoCapture("sample.mp4")
122
  while True:
123
+ ret, frame = video.read()
124
  if not ret:
125
  break
126
+ gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
127
+ cv2.imshow("Grayscale Video", gray_frame)
128
  if cv2.waitKey(1) & 0xFF == ord('q'):
129
  break
130
+ video.release()
131
+ cv2.destroyAllWindows()
132
+ """, language="python")
133
+
134
+ # Section 5: Image Processing with OpenCV
135
+ st.header("Image Processing Techniques")
136
+ st.write("""
137
+ OpenCV is a powerful library for working with images and videos. It provides tools for:
138
+ - Reading and writing images
139
+ - Manipulating color spaces
140
+ - Applying filters and transformations
141
+ """)
142
+
143
+ # Subsection: Reading an Image
144
+ st.subheader("Reading and Displaying an Image")
145
+ st.code("""
146
+ import cv2
147
+
148
+ # Load an image
149
+ image = cv2.imread("image.jpg")
150
+
151
+ # Display the image
152
+ cv2.imshow("Image", image)
153
+ cv2.waitKey(0)
154
+ cv2.destroyAllWindows()
155
+ """, language="python")
156
+
157
+ # Subsection: Color Conversion
158
+ st.subheader("Color Space Conversion")
159
+ st.code("""
160
+ import cv2
161
+
162
+ # Convert an image to grayscale
163
+ image = cv2.imread("image.jpg")
164
+ gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
165
+ cv2.imshow("Grayscale Image", gray_image)
166
+ cv2.waitKey(0)
167
  cv2.destroyAllWindows()
168
+ """, language="python")
169
+
170
+ # Section 6: Upload Your Image
171
+ st.header("Try It Yourself")
172
+ uploaded_file = st.file_uploader("Upload an Image", type=["jpg", "png"])
173
+ if uploaded_file:
174
+ image = Image.open(uploaded_file)
175
+ st.image(image, caption="Uploaded Image", use_column_width=True)
176
+ st.write(f"Image Format: {image.format}")
177
+ st.write(f"Image Size: {image.size}")
178
+ st.write(f"Color Mode: {image.mode}")
179
+
180
+ # Section 7: Key Takeaways
181
+ st.header("Key Takeaways")
182
+ st.markdown("""
183
+ <ul class="icon-bullet">
184
+ <li>Unstructured data is diverse and valuable.</li>
185
+ <li>Images and videos require specialized tools for processing.</li>
186
+ <li>OpenCV simplifies image and video manipulation.</li>
187
+ </ul>
188
+ """, unsafe_allow_html=True)
189
+
190
+ st.write("Created with ❤️ using Streamlit")
191
+
192
+
193
+