Update app.py
Browse files
app.py
CHANGED
|
@@ -33,47 +33,52 @@ st.markdown("Welcome to the Hugging Face Agent and Tools app! This app allows yo
|
|
| 33 |
import pandas as pd
|
| 34 |
from io import StringIO
|
| 35 |
with st.sidebar:
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
pdf_document = uploaded_file.getvalue()
|
| 48 |
-
document = pdf_document
|
| 49 |
-
st.write(pdf_document)
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
txt_document = uploaded_txt_file.getvalue()
|
| 55 |
-
document = txt_document
|
| 56 |
-
st.write(txt_document)
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 62 |
-
document = csv_document
|
| 63 |
-
st.write(csv_document)
|
| 64 |
-
|
| 65 |
-
# To convert to a string based IO:
|
| 66 |
-
#stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 67 |
-
#st.write(stringio)
|
| 68 |
|
| 69 |
-
# To read file as string:
|
| 70 |
-
#string_data = stringio.read()
|
| 71 |
-
#st.write(string_data)
|
| 72 |
-
|
| 73 |
-
# Can be used wherever a "file-like" object is accepted:
|
| 74 |
-
dataframe = pd.read_csv(uploaded_file)
|
| 75 |
-
st.write(dataframe)
|
| 76 |
-
|
| 77 |
|
| 78 |
|
| 79 |
# Create a page with tabs
|
|
|
|
| 33 |
import pandas as pd
|
| 34 |
from io import StringIO
|
| 35 |
with st.sidebar:
|
| 36 |
+
with st.expander("See explanation"):
|
| 37 |
+
|
| 38 |
+
img_file_buffer = st.file_uploader('Upload a PNG image', type='png')
|
| 39 |
+
if img_file_buffer is not None:
|
| 40 |
+
image_raw = Image.open(img_file_buffer)
|
| 41 |
+
global image
|
| 42 |
+
image = np.array(image_raw)
|
| 43 |
+
########
|
| 44 |
+
st.image(image)
|
| 45 |
+
|
| 46 |
+
uploaded_file = st.file_uploader("Choose a file", type='pdf')
|
| 47 |
+
if uploaded_file is not None:
|
| 48 |
+
# To read file as bytes:
|
| 49 |
+
pdf_document = uploaded_file.getvalue()
|
| 50 |
+
global document
|
| 51 |
+
document = pdf_document
|
| 52 |
+
st.write(pdf_document)
|
| 53 |
+
|
| 54 |
+
uploaded_txt_file = st.file_uploader("Choose a file", type='txt')
|
| 55 |
+
if uploaded_txt_file is not None:
|
| 56 |
+
# To read file as bytes:
|
| 57 |
+
txt_document = uploaded_txt_file.getvalue()
|
| 58 |
+
global document
|
| 59 |
+
document = txt_document
|
| 60 |
+
st.write(txt_document)
|
| 61 |
+
|
| 62 |
+
uploaded_csv_file = st.file_uploader("Choose a file", type='csv')
|
| 63 |
+
if uploaded_csv_file is not None:
|
| 64 |
+
# To read file as bytes:
|
| 65 |
+
csv_document = uploaded_csv_file.getvalue()
|
| 66 |
+
global document
|
| 67 |
+
document = csv_document
|
| 68 |
+
st.write(csv_document)
|
| 69 |
|
| 70 |
+
# To convert to a string based IO:
|
| 71 |
+
#stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 72 |
+
#st.write(stringio)
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
# To read file as string:
|
| 75 |
+
#string_data = stringio.read()
|
| 76 |
+
#st.write(string_data)
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
# Can be used wherever a "file-like" object is accepted:
|
| 79 |
+
dataframe = pd.read_csv(uploaded_file)
|
| 80 |
+
st.write(dataframe)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
# Create a page with tabs
|