Phani1008 commited on
Commit
5d3bc6b
Β·
verified Β·
1 Parent(s): a766cbc

Update pages/Types of Data.py

Browse files
Files changed (1) hide show
  1. pages/Types of Data.py +53 -452
pages/Types of Data.py CHANGED
@@ -1,7 +1,11 @@
1
-
2
  import streamlit as st
3
  from streamlit_lottie import st_lottie
4
  import requests
 
 
 
 
 
5
 
6
  # Function to load Lottie animation from a URL
7
  def load_lottie_url(url: str):
@@ -11,487 +15,84 @@ def load_lottie_url(url: str):
11
  return r.json()
12
 
13
  # Load animations using URLs
14
- structured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_4j6cnjjm.json" # Example URL for structured data
15
- semi_structured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_0fhcmhgf.json" # Example URL for semi-structured data
16
- unstructured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_rekwjvy0.json" # Example URL for unstructured data
17
 
18
  # Sidebar navigation
19
  st.sidebar.title("Navigation")
20
  page = st.sidebar.radio("Choose a page", ["Home", "Structured Data", "Semi-Structured Data", "Unstructured Data"])
21
 
22
- # Home Page: Overview of What is Data and Types of Data
23
  if page == "Home":
24
  st.title("Understanding Data and Its Types 🌐")
25
-
26
  st.header("What is Data?")
27
  st.write("""
28
  **Data** refers to raw facts, figures, or information that can be collected, measured, and analyzed for specific purposes.
29
  It serves as the foundation for generating insights, making decisions, and solving problems in various fields like business,
30
  science, and technology. 🧠
31
  """)
32
-
33
  st.header("Types of Data πŸ“Š")
34
  st.write("Data can exist in various forms depending on its source and nature. Common forms include:")
35
  st.markdown("""
36
- 1. **Structured Data**: Data organized in a predefined format, making it easily searchable and manageable.
37
- 2. **Semi-Structured Data**: Data that does not have a strict schema but is partially organized using tags or markers.
38
- 3. **Unstructured Data**: Data without any predefined structure, requiring specialized tools to analyze.
39
  """)
40
 
41
- # Structured Data Page
42
  elif page == "Structured Data":
43
  st.title("Structured Data πŸ“‹")
44
  animation = load_lottie_url(structured_animation_url)
45
  if animation:
46
  st_lottie(animation, height=300, key="structured_animation")
47
-
48
- st.write("""
49
- **Definition**: Structured data refers to data that is organized and stored in a predefined format like rows and columns, making it easily searchable and manageable.
50
- It is highly organized, and each data point is placed into a defined structure.
51
- """)
52
-
53
- st.write("**Features**:")
54
- st.markdown("""
55
- - Fixed schema (e.g., tables with defined columns and data types).
56
- - Easy to process and analyze using query languages like SQL.
57
- - Relationships between data points are well-defined.
58
- """)
59
-
60
- st.write("**Examples of Structured Data**:")
61
- st.markdown("""
62
- 1. **Excel Files** πŸ“Š
63
- 2. **MySQL Databases** πŸ’Ύ
64
- """)
65
-
66
-
67
- # Buttons for Structured Data Examples
68
- if st.button("Show Excel Files πŸ“‚"):
69
- st.subheader("Excel Files")
70
- st.write("""
71
- Excel files store structured data in rows and columns. They allow for easy calculations, analysis, and data manipulation using formulas or pivot tables.
72
- Excel is a widely used tool in business, finance, and data analytics.
73
- """)
74
- # In the Structured Data page, add the following for the Excel button:
75
- st.subheader("Excel Files")
76
- st.write("""
77
- **Excel** is a spreadsheet application developed by Microsoft. It stores structured data in rows and columns,
78
- making it ideal for data analysis, calculations, and visualization.
79
- **Key Features of Excel:**
80
- - Store, analyze, and visualize data in tabular format.
81
- - Support for formulas, functions, and pivot tables for advanced data manipulation.
82
- - Integration with other applications and databases.
83
- - Support for multiple sheets in a single workbook.
84
- **Common Extensions:**
85
- - `.xlsx` (default format for modern Excel)
86
- - `.xls` (older format for Excel)
87
- - `.csv` (Comma-Separated Values, compatible with Excel)
88
- **How to Handle Excel Files in Python:**
89
- Python provides libraries like `pandas` and `openpyxl` for reading, writing, and processing Excel files.
90
- """)
91
-
92
- st.write("### Convert Excel to CSV πŸ“„")
93
- st.code("""
94
- import pandas as pd
95
- # Convert a single Excel sheet to CSV
96
- def excel_to_csv(excel_file, csv_file):
97
- df = pd.read_excel(excel_file) # Read the Excel file
98
- df.to_csv(csv_file, index=False) # Save as CSV
99
- print(f"Excel file converted to {csv_file}")
100
- # Example usage
101
- excel_to_csv('input_file.xlsx', 'output_file.csv')
102
- """, language="python")
103
-
104
- st.write("### Convert Multiple Sheets to CSV πŸ“„")
105
- st.code("""
106
- import pandas as pd
107
- # Convert all sheets in an Excel file to separate CSV files
108
- def excel_sheets_to_csv(excel_file, output_dir):
109
- # Read all sheets
110
- sheets = pd.read_excel(excel_file, sheet_name=None)
111
- for sheet_name, data in sheets.items():
112
- csv_file = f"{output_dir}/{sheet_name}.csv" # Name CSV files by sheet name
113
- data.to_csv(csv_file, index=False)
114
- print(f"Sheet '{sheet_name}' converted to {csv_file}")
115
- # Example usage
116
- excel_sheets_to_csv('input_file.xlsx', 'output_directory')
117
- """, language="python")
118
-
119
- # Placeholder button for GitHub link
120
- if st.button("GitHub Link πŸ”—"):
121
- st.write("**GitHub Repository:** [Provide your GitHub link here]")
122
-
123
- # Optional: Add an animation for Excel
124
- excel_animation_url = "https://assets9.lottiefiles.com/packages/lf20_ktn4ouly.json" # Example Lottie URL for Excel
125
- excel_animation = load_lottie_url(excel_animation_url)
126
- if excel_animation:
127
- st_lottie(excel_animation, height=300, key="excel_animation")
128
 
129
- if st.button("Show MySQL Databases πŸ’»"):
130
- st.subheader("MySQL Databases")
131
- st.write("""
132
- MySQL is a relational database management system that stores structured data in tables. SQL (Structured Query Language) is used to query and manipulate data in these databases.
133
- It is commonly used in web applications and enterprise systems.
134
- """)
135
-
136
- st.write("""
137
- **MySQL** is an open-source relational database management system (RDBMS) that stores structured data in tables.
138
- It is widely used for managing and organizing data in web applications, enterprise systems, and data-driven projects.
139
- **Key Features of MySQL:**
140
- - High performance, scalability, and reliability.
141
- - Support for SQL (Structured Query Language) for querying and managing data.
142
- - Multi-user access and role-based permissions.
143
- - Integration with multiple programming languages like Python, PHP, Java, etc.
144
- **Common Use Cases:**
145
- - Web application backends (e.g., WordPress, e-commerce platforms).
146
- - Data analytics and reporting.
147
- - Content management systems (CMS).
148
-
149
- **MySQL Extensions:**
150
- - `.sql`: Standard file extension for SQL database dumps.
151
- - `.db`: Extension used by certain database systems but can also represent MySQL databases.
152
- """)
153
-
154
- st.write("""
155
- ### Advantages of MySQL:
156
- - Open-source and free to use.
157
- - Cross-platform support (Windows, Linux, macOS).
158
- - Regular updates and strong community support.
159
- - Supports ACID compliance for data reliability.
160
- ### Limitations of MySQL:
161
- - Not as feature-rich as some enterprise-level database systems (e.g., Oracle, MS SQL Server).
162
- - Limited support for advanced analytics and distributed databases.
163
- """)
164
-
165
- # Placeholder button for GitHub link
166
- if st.button("GitHub Link πŸ”—"):
167
- st.write("**GitHub Repository:** [Provide your GitHub link here]")
168
-
169
- # Optional: Add an animation for MySQL
170
- mysql_animation_url = "https://assets10.lottiefiles.com/packages/lf20_kq5msyia.json" # Example Lottie URL for MySQL
171
- mysql_animation = load_lottie_url(mysql_animation_url)
172
- if mysql_animation:
173
- st_lottie(mysql_animation, height=300, key="mysql_animation")
174
-
175
-
176
- # Semi-Structured Data Page
177
  elif page == "Semi-Structured Data":
178
- st.title("Semi-Structured Data 🧩")
179
  animation = load_lottie_url(semi_structured_animation_url)
180
  if animation:
181
  st_lottie(animation, height=300, key="semi_structured_animation")
182
-
183
- st.write("""
184
- **Definition**: Semi-structured data does not have a strict table-based format but is partially organized using tags, markers, or key-value pairs.
185
- While it is more flexible than structured data, it still has some organizational components.
186
- """)
187
-
188
- st.write("**Features**:")
189
- st.markdown("""
190
- - Flexible schema; not bound to a rigid structure.
191
- - Easier to manage than unstructured data but more complex than structured data.
192
- """)
193
-
194
- st.write("**Examples of Semi-Structured Data**:")
195
- st.markdown("""
196
- 1. **JSON Files** πŸ“‘
197
- 2. **XML Files** 🌐
198
- """)
199
-
200
- # Buttons for Semi-Structured Data Examples
201
- if st.button("Show JSON Files πŸ“„"):
202
- st.subheader("JSON Files")
203
- st.write("""
204
- **JSON (JavaScript Object Notation)** is a lightweight data-interchange format. It is easy for humans to read and write, and it is easy for machines to parse and generate. JSON is widely used to transmit data between a server and a web application.
205
- **Key Features of JSON:**
206
- - Stores data as key-value pairs.
207
- - Supports nested structures, such as arrays and objects.
208
- - Language-independent but derived from JavaScript.
209
- **Common Use Cases:**
210
- - API responses and requests in web development.
211
- - Configuration files for applications.
212
- - Data serialization and exchange in distributed systems.
213
- **File Extension:**
214
- - `.json`
215
- **Advantages of JSON:**
216
- - Lightweight and compact.
217
- - Human-readable and easy to understand.
218
- - Supported by most modern programming languages.
219
- **Limitations of JSON:**
220
- - Does not support comments.
221
- - Less efficient for very large datasets compared to binary formats.
222
- """)
223
 
224
- st.write("### Python Example: Working with JSON πŸ“„")
225
- st.write("#### Reading a JSON File and Accessing Its Data")
226
- st.code("""
227
- import json
228
- # Reading a JSON file
229
- with open('data.json', 'r') as file:
230
- data = json.load(file)
231
- # Accessing data
232
- print("Name:", data['name'])
233
- print("Age:", data['age'])
234
- """, language="python")
235
-
236
- st.write("#### Writing Data to a JSON File")
237
- st.code("""
238
- # Writing data to a JSON file
239
- new_data = {
240
- "name": "John Doe",
241
- "age": 30,
242
- "city": "New York"
243
- }
244
- with open('output.json', 'w') as file:
245
- json.dump(new_data, file, indent=4)
246
- print("Data saved to output.json")
247
- """, language="python")
248
-
249
- # Placeholder button for GitHub link
250
- if st.button("GitHub Link πŸ”— (JSON)"):
251
- st.write("**GitHub Repository:** [Provide your GitHub link here]")
252
-
253
- # Optional: Add animation for JSON
254
- json_animation_url = "https://assets9.lottiefiles.com/packages/lf20_9jdtwwzw.json" # Example Lottie URL for JSON
255
- json_animation = load_lottie_url(json_animation_url)
256
- if json_animation:
257
- st_lottie(json_animation, height=300, key="json_animation")
258
-
259
- # XML Button
260
- if st.button("Show XML Files πŸ“„"):
261
- st.subheader("XML Files")
262
- st.write("""
263
- **XML (eXtensible Markup Language)** is a markup language designed to store and transport data. XML emphasizes simplicity, generality, and usability across the Internet.
264
- **Key Features of XML:**
265
- - Data is stored in a tree-like structure with nested elements.
266
- - Customizable tags allow flexibility in representing data.
267
- - Both human-readable and machine-readable.
268
- **Common Use Cases:**
269
- - Data interchange between systems.
270
- - Configuration files for applications and servers.
271
- - RSS feeds and web services (e.g., SOAP).
272
- **File Extension:**
273
- - `.xml`
274
- **Advantages of XML:**
275
- - Highly flexible and customizable.
276
- - Self-descriptive and easy to understand.
277
- - Widely supported in web and enterprise applications.
278
- **Limitations of XML:**
279
- - More verbose compared to JSON.
280
- - Slower to parse and larger in size.
281
- """)
282
-
283
- st.write("### Python Example: Working with XML πŸ“„")
284
- st.write("#### Reading an XML File and Parsing Its Data")
285
- st.code("""
286
- import xml.etree.ElementTree as ET
287
- # Parsing an XML file
288
- tree = ET.parse('data.xml')
289
- root = tree.getroot()
290
- # Accessing data
291
- for child in root:
292
- print(child.tag, ":", child.text)
293
- """, language="python")
294
-
295
- st.write("#### Writing Data to an XML File")
296
- st.code("""
297
- import xml.etree.ElementTree as ET
298
- # Creating an XML structure
299
- root = ET.Element("person")
300
- name = ET.SubElement(root, "name")
301
- name.text = "John Doe"
302
- age = ET.SubElement(root, "age")
303
- age.text = "30"
304
- # Writing to a file
305
- tree = ET.ElementTree(root)
306
- tree.write("output.xml")
307
- print("Data saved to output.xml")
308
- """, language="python")
309
-
310
- # Placeholder button for GitHub link
311
- if st.button("GitHub Link πŸ”— (XML)"):
312
- st.write("**GitHub Repository:** [Provide your GitHub link here]")
313
-
314
- # Optional: Add animation for XML
315
- xml_animation_url = "https://assets7.lottiefiles.com/packages/lf20_7ozhpxio.json" # Example Lottie URL for XML
316
- xml_animation = load_lottie_url(xml_animation_url)
317
- if xml_animation:
318
- st_lottie(xml_animation, height=300, key="xml_animation")
319
-
320
-
321
- # Unstructured Data Page
322
  elif page == "Unstructured Data":
323
- st.title("Unstructured Data πŸ—‚οΈ")
324
  animation = load_lottie_url(unstructured_animation_url)
325
  if animation:
326
  st_lottie(animation, height=300, key="unstructured_animation")
327
-
328
- st.write("""
329
- **Definition**: Unstructured data lacks any predefined structure or schema, making it the most difficult to organize and analyze.
330
- It is typically raw and needs advanced processing to extract insights.
331
- """)
332
-
333
- st.write("**Features**:")
334
- st.markdown("""
335
- - Free-form; not stored in a tabular format.
336
- - Requires specialized tools like AI or machine learning to analyze.
337
- """)
338
-
339
- st.write("**Examples of Unstructured Data**:")
340
- st.markdown("""
341
- 1. **Images πŸ–ΌοΈ**
342
- 2. **Videos πŸŽ₯**
343
- 3. **Audio πŸ”Š**
344
- 4. **Text πŸ–Ή**
345
- """)
346
-
347
- # Buttons for Unstructured Data Examples
348
- if st.button("Show Image πŸ“·"):
349
- st.subheader("Working with Images")
350
- st.write("""
351
- **Images** are one of the most common forms of unstructured data. They are represented as a grid of pixels, each having color information (RGB or grayscale). Images are used in various domains such as computer vision, medical imaging, and entertainment.
352
- **Common File Formats:**
353
- - `.jpg` or `.jpeg` (Joint Photographic Experts Group)
354
- - `.png` (Portable Network Graphics)
355
- - `.bmp` (Bitmap Image File)
356
- - `.tiff` (Tagged Image File Format)
357
- """)
358
-
359
- st.write("### Steps to Convert an Image into an Array πŸ“Š")
360
- st.write("""
361
- Converting an image into a numerical array is a key step in image processing. Here's how it's typically done:
362
- 1. Load the image using an image processing library (e.g., OpenCV or PIL).
363
- 2. Convert the image into a NumPy array.
364
- 3. Access pixel data for analysis or manipulation.
365
- """)
366
-
367
- st.write("#### Example Code: Converting an Image into an Array")
368
- st.code("""
369
- import cv2
370
- import numpy as np
371
- # Load the image
372
- image_path = 'image.jpg' # Path to the image
373
- image = cv2.imread(image_path) # Load image as BGR format
374
- # Convert to NumPy array
375
- image_array = np.array(image)
376
- # Display shape and pixel data
377
- print("Image Shape:", image_array.shape) # (Height, Width, Channels)
378
- print("Pixel Data (Top-left):", image_array[0, 0]) # Pixel value at (0, 0)
379
- """, language="python")
380
-
381
-
382
- from transformers import pipeline
383
- import gradio as gr
384
- from PIL import Image, ImageOps
385
- import numpy as np
386
- import random
387
-
388
- # Function for image augmentation
389
- def augment_image(image, crop_size, flip, rotation):
390
- img = Image.fromarray(image)
391
-
392
- # Crop
393
- if crop_size > 0:
394
- width, height = img.size
395
- left = random.randint(0, crop_size)
396
- top = random.randint(0, crop_size)
397
- right = width - random.randint(0, crop_size)
398
- bottom = height - random.randint(0, crop_size)
399
- img = img.crop((left, top, right, bottom))
400
-
401
- # Flip
402
- if flip:
403
- img = ImageOps.mirror(img)
404
-
405
- # Rotate
406
- if rotation != 0:
407
- img = img.rotate(rotation, expand=True)
408
-
409
- return np.array(img)
410
-
411
- # Gradio interface
412
- def interface(image, crop_size, flip, rotation):
413
- augmented_image = augment_image(image, crop_size, flip, rotation)
414
- return augmented_image
415
-
416
- app = gr.Interface(
417
- fn=interface,
418
- inputs=[
419
- gr.Image(type="numpy"),
420
- gr.Slider(0, 100, step=1, label="Crop Size"),
421
- gr.Checkbox(label="Flip"),
422
- gr.Slider(0, 360, step=1, label="Rotation Angle")
423
- ],
424
- outputs=gr.Image(type="numpy"),
425
- title="Image Augmentation Tool",
426
- description="Upload an image to apply cropping, flipping, and rotation."
427
- )
428
-
429
- if __name__ == "__main__":
430
- app.launch()
431
-
432
-
433
- # Placeholder button for GitHub link
434
- if st.button("Jupyter Notebook πŸ”— (Image)"):
435
- st.markdown("https://colab.research.google.com/drive/1BxJuxD1mzeuDnPIjwc-06J_GIU2JgO1_?usp=sharing")
436
-
437
- if st.button("Show Video πŸŽ₯"):
438
- st.subheader("Working with Videos")
439
- st.write("""
440
- **Videos** are sequences of images (frames) that are displayed at a specific frame rate to create a moving picture. Videos are used in surveillance, entertainment, and machine learning applications like activity recognition and object detection.
441
- **Common File Formats:**
442
- - `.mp4` (MPEG-4 Part 14)
443
- - `.avi` (Audio Video Interleave)
444
- - `.mov` (QuickTime File Format)
445
- - `.mkv` (Matroska Video File Format)
446
- """)
447
-
448
- st.write("### Steps to Convert a Video into Frames πŸ“Έ")
449
- st.write("""
450
- Breaking a video into individual frames is an important step in video analysis. Here's how it's done:
451
- 1. Load the video using a video processing library like OpenCV.
452
- 2. Loop through each frame and save or process it.
453
- 3. Save the frames as images for further processing.
454
- """)
455
-
456
- st.write("#### Example Code: Converting a Video into Frames")
457
- st.code("""
458
- import cv2
459
- import os
460
- # Load the video
461
- video_path = 'video.mp4' # Path to the video
462
- video = cv2.VideoCapture(video_path)
463
- # Create a folder to store the frames
464
- output_folder = 'frames'
465
- os.makedirs(output_folder, exist_ok=True)
466
- frame_number = 0
467
- while True:
468
- ret, frame = video.read() # Read the next frame
469
- if not ret:
470
- break # Exit if no frames are left
471
- # Save the frame as an image
472
- frame_path = os.path.join(output_folder, f'frame_{frame_number:04d}.jpg')
473
- cv2.imwrite(frame_path, frame)
474
- frame_number += 1
475
- print(f"Extracted {frame_number} frames and saved to {output_folder}")
476
- video.release()
477
- """, language="python")
478
-
479
- # Placeholder button for GitHub link
480
- if st.button("GitHub Link πŸ”— (Video)"):
481
- st.write("**GitHub Repository:** [Provide your GitHub link here]")
482
-
483
-
484
- if st.button("Show Audio πŸ”Š"):
485
- st.subheader("Audio")
486
- st.write("""
487
- Social media posts, such as tweets, Facebook updates, or Instagram images, represent unstructured data. They contain a mix of text, images, and metadata and require NLP (Natural Language Processing) for analysis.
488
- """)
489
-
490
- if st.button("Show Text πŸ“"):
491
- st.subheader("Text")
492
- st.write("""
493
- Social media posts, such as tweets, Facebook updates, or Instagram images, represent unstructured data. They contain a mix of text, images, and metadata and require NLP (Natural Language Processing) for analysis.
494
- """)
495
-
496
- # Footer
497
- st.write("This app provides a clear understanding of data and its various types, especially based on structure. πŸŽ‰")
 
 
1
  import streamlit as st
2
  from streamlit_lottie import st_lottie
3
  import requests
4
+ from transformers import pipeline
5
+ import gradio as gr
6
+ from PIL import Image, ImageOps
7
+ import numpy as np
8
+ import random
9
 
10
  # Function to load Lottie animation from a URL
11
  def load_lottie_url(url: str):
 
15
  return r.json()
16
 
17
  # Load animations using URLs
18
+ structured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_4j6cnjjm.json"
19
+ semi_structured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_0fhcmhgf.json"
20
+ unstructured_animation_url = "https://assets10.lottiefiles.com/packages/lf20_rekwjvy0.json"
21
 
22
  # Sidebar navigation
23
  st.sidebar.title("Navigation")
24
  page = st.sidebar.radio("Choose a page", ["Home", "Structured Data", "Semi-Structured Data", "Unstructured Data"])
25
 
 
26
  if page == "Home":
27
  st.title("Understanding Data and Its Types 🌐")
 
28
  st.header("What is Data?")
29
  st.write("""
30
  **Data** refers to raw facts, figures, or information that can be collected, measured, and analyzed for specific purposes.
31
  It serves as the foundation for generating insights, making decisions, and solving problems in various fields like business,
32
  science, and technology. 🧠
33
  """)
34
+
35
  st.header("Types of Data πŸ“Š")
36
  st.write("Data can exist in various forms depending on its source and nature. Common forms include:")
37
  st.markdown("""
38
+ 1. **Structured Data**
39
+ 2. **Semi-Structured Data**
40
+ 3. **Unstructured Data**
41
  """)
42
 
 
43
  elif page == "Structured Data":
44
  st.title("Structured Data πŸ“‹")
45
  animation = load_lottie_url(structured_animation_url)
46
  if animation:
47
  st_lottie(animation, height=300, key="structured_animation")
48
+ st.write("Structured data is organized in rows and columns, like in databases and spreadsheets.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  elif page == "Semi-Structured Data":
51
+ st.title("Semi-Structured Data 🧬")
52
  animation = load_lottie_url(semi_structured_animation_url)
53
  if animation:
54
  st_lottie(animation, height=300, key="semi_structured_animation")
55
+ st.write("Semi-structured data includes JSON, XML, and other formats that have some organizational properties.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  elif page == "Unstructured Data":
58
+ st.title("Unstructured Data πŸ—‚")
59
  animation = load_lottie_url(unstructured_animation_url)
60
  if animation:
61
  st_lottie(animation, height=300, key="unstructured_animation")
62
+ st.write("Unstructured data includes images, videos, and text that do not follow a specific schema.")
63
+
64
+ # Gradio Interface for Image Augmentation
65
+ def augment_image(image, crop_size, flip, rotation):
66
+ img = Image.fromarray(image)
67
+ if crop_size > 0:
68
+ width, height = img.size
69
+ left = random.randint(0, crop_size)
70
+ top = random.randint(0, crop_size)
71
+ right = width - random.randint(0, crop_size)
72
+ bottom = height - random.randint(0, crop_size)
73
+ img = img.crop((left, top, right, bottom))
74
+ if flip:
75
+ img = ImageOps.mirror(img)
76
+ if rotation != 0:
77
+ img = img.rotate(rotation, expand=True)
78
+ return np.array(img)
79
+
80
+ def interface(image, crop_size, flip, rotation):
81
+ augmented_image = augment_image(image, crop_size, flip, rotation)
82
+ return augmented_image
83
+
84
+ app = gr.Interface(
85
+ fn=interface,
86
+ inputs=[
87
+ gr.Image(type="numpy"),
88
+ gr.Slider(0, 100, step=1, label="Crop Size"),
89
+ gr.Checkbox(label="Flip"),
90
+ gr.Slider(0, 360, step=1, label="Rotation Angle")
91
+ ],
92
+ outputs=gr.Image(type="numpy"),
93
+ title="Image Augmentation Tool",
94
+ description="Upload an image to apply cropping, flipping, and rotation."
95
+ )
96
+
97
+ if st.button("Launch Image Augmentation Tool"):
98
+ app.launch()