cv-to-json / app.py
Essa20001's picture
Update app.py
2066b6c verified
import streamlit as st
from yolo_text_extraction import extract_text_from_sections, cv_to_json
import json
import subprocess
import io
import subprocess
import sys
import os
def main():
st.title("CV to JSON Converter")
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")
if uploaded_file is not None:
if st.button("Convert to JSON"):
try:
file_like_object = io.BytesIO(uploaded_file.read())
# Pass the file-like object to cv_to_json
result = cv_to_json(file_like_object)
st.json(result)
# Option to download the JSON
st.download_button(
label="Download JSON",
data=json.dumps(result, indent=2),
file_name="cv_data.json",
mime="application/json"
)
except Exception as e:
st.error(f"An error occurred: {str(e)}")
if __name__ == "__main__":
main()