Spaces:
Build error
Build error
File size: 2,135 Bytes
575ba46 340d62c 2de22c5 575ba46 7aa5aee 0ffba2d 5adc781 7aa5aee e81e4c2 7aa5aee 5adc781 7aa5aee 0ffba2d 4b180d1 0ffba2d 2bd4c2f 7aa5aee 53e9a7d 340d62c b614604 340d62c 53e9a7d 7aa5aee 53e9a7d 7aa5aee 340d62c 53e9a7d 5b0a5c8 340d62c b614604 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import streamlit as st
import subprocess
import camelot
# Function to install dependencies
def install_dependencies():
try:
import plotly
except ImportError:
st.write("Installing plotly...")
subprocess.check_call(["pip", "install", "plotly", "camelot-py[cv]"])
st.write("plotly installed successfully.")
# Install other dependencies if needed
required_libraries = ["torch", "transformers", "pdfplumber", "camelot-py[cv]", "pandas"]
for library in required_libraries:
try:
__import__(library)
except ImportError:
st.write(f"Installing {library}...")
subprocess.check_call(["pip", "install", library])
st.write(f"{library} installed successfully.")
# Install dependencies
install_dependencies()
# Title and Description
st.title("Automated Datasheet Summarizer with Table Parsing")
st.write("Upload a datasheet PDF or enter a component name to get simplified summaries, key specs, and visual insights.")
# Input Options
input_type = st.radio("Select Input Type:", ["Upload PDF", "Enter Component Name"])
if input_type == "Upload PDF":
uploaded_file = st.file_uploader("Upload a Datasheet PDF", type=["pdf"])
if uploaded_file is not None:
try:
# Parse tables using Camelot
tables = camelot.read_pdf(uploaded_file, pages="all")
if len(tables) > 0:
for i, table in enumerate(tables):
st.write(f"Table {i+1}")
st.dataframe(table.df)
else:
st.warning("No tables found in the PDF.")
except Exception as e:
st.error(f"Error parsing tables with Camelot: {e}")
elif input_type == "Enter Component Name":
component_name = st.text_input("Enter Component Name")
if component_name and st.button("Search and Summarize"):
st.error("Component search functionality is under development.")
# Footer
st.markdown("---")
st.markdown("**Note:** This tool is in beta. Accuracy of the generated summaries and parsed tables depends on the quality of the datasheet.")
|