File size: 1,868 Bytes
3de6e4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fffa84f
3de6e4d
 
 
 
 
 
 
 
 
17945bd
fffa84f
3de6e4d
 
 
 
 
 
 
c253af2
3de6e4d
 
 
 
 
 
 
 
 
 
 
 
d3b93e6
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
import streamlit as st
import llm
from file_creator import Create_Doc

model = llm.Model()
unvalid_image_text = 'please upload a valid screenshot.'

st.markdown("""
    <style>
    .justified-text {
        text-align: justify;
    }
    </style>
    """, unsafe_allow_html=True)


with st.sidebar:
    st.header("ABOUT:")
    
    st.caption("""
        <div class="justified-text">
           Image to Document file Creator is an AI powered app that allows users to effortlessly convert their screenshots into Word documents. Simply upload a screenshot, and the app will generate a Word document based on the image provided, ensuring a seamless and efficient conversion process. Ideal for anyone looking to quickly turn visual content into editable text documents.
        </div>
        """, unsafe_allow_html=True)
    
    for _ in range(17):
        st.write("") 
    st.subheader("Build By:")
    st.write("[Pachaiappan❤️](https://mr-vicky-01.github.io/Portfolio)")
    st.write("contact: [Email](mailto:[email protected])")

st.title("Image🖼️ - Document📃")
st.text("Upload your screenshot or image to convert it into a Word document.")
uploaded_file = st.file_uploader("", type=["png", "jpg", "jpeg"])

if uploaded_file:
    st.image(uploaded_file)
    
    button = st.button("Generate Document")
    if button:
        with st.spinner("🤖Preparing your Document..."):
            text = model.get_response(uploaded_file)
        st.write(text)
        
        if text.lower().strip() != unvalid_image_text:
            doc = Create_Doc()
            doc_buffer = doc.markdown_to_word(text)
            st.download_button(
            label="Download",
            data=doc_buffer,
            file_name="output.docx",
            mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            )