hertogateis commited on
Commit
9aaa1ae
·
verified ·
1 Parent(s): 0a87f1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
3
  from st_aggrid import AgGrid
4
  import pandas as pd
5
  from transformers import pipeline, T5ForConditionalGeneration, T5Tokenizer
 
6
 
7
  # Set the page layout for Streamlit
8
  st.set_page_config(layout="wide")
@@ -94,6 +95,21 @@ else:
94
  st.write(f"Coordinates: {coordinates}")
95
  st.write(f"Cells: {cells}")
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  except Exception as e:
98
  st.warning(f"Error processing question or generating answer: {str(e)}")
99
  st.warning("Please retype your question and make sure to use the column name and cell value correctly.")
 
3
  from st_aggrid import AgGrid
4
  import pandas as pd
5
  from transformers import pipeline, T5ForConditionalGeneration, T5Tokenizer
6
+ import matplotlib.pyplot as plt
7
 
8
  # Set the page layout for Streamlit
9
  st.set_page_config(layout="wide")
 
95
  st.write(f"Coordinates: {coordinates}")
96
  st.write(f"Cells: {cells}")
97
 
98
+ # If cells are returned, we will extract the corresponding values for plotting
99
+ if cells:
100
+ # For simplicity, let's assume cells contain data we want to plot (e.g., numeric data)
101
+ cell_values = [float(cell['value']) for cell in cells if cell['value'].isnumeric()]
102
+ column_names = [cell['column'] for cell in cells]
103
+
104
+ # Plot the data
105
+ if len(cell_values) > 0 and len(column_names) > 0:
106
+ fig, ax = plt.subplots()
107
+ ax.bar(column_names, cell_values)
108
+ ax.set_xlabel('Columns')
109
+ ax.set_ylabel('Values')
110
+ ax.set_title('Bar Plot of TAPAS Answer')
111
+ st.pyplot(fig)
112
+
113
  except Exception as e:
114
  st.warning(f"Error processing question or generating answer: {str(e)}")
115
  st.warning("Please retype your question and make sure to use the column name and cell value correctly.")