Spaces:
Sleeping
Sleeping
Update pages/Types of Data.py
Browse files- pages/Types of Data.py +23 -96
pages/Types of Data.py
CHANGED
|
@@ -1,98 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
st.
|
| 28 |
-
|
| 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()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import sys
|
| 4 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Install transformers if not already installed
|
| 7 |
+
try:
|
| 8 |
+
from transformers import pipeline
|
| 9 |
+
except ModuleNotFoundError:
|
| 10 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "transformers"])
|
| 11 |
+
from transformers import pipeline
|
| 12 |
+
|
| 13 |
+
# Title
|
| 14 |
+
st.title("Data Types Analysis with Transformers")
|
| 15 |
+
|
| 16 |
+
# User input
|
| 17 |
+
user_input = st.text_area("Enter your text here:")
|
| 18 |
+
|
| 19 |
+
if user_input:
|
| 20 |
+
classifier = pipeline("sentiment-analysis")
|
| 21 |
+
result = classifier(user_input)
|
| 22 |
+
st.write("### Sentiment Analysis Result:")
|
| 23 |
+
st.write(result)
|
| 24 |
+
else:
|
| 25 |
+
st.write("Please enter some text to analyze.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|