#๐Ÿ”’ Ocr Implementation in a webapp using streamlit

75 messages ยท Page 1 of 1 (latest)

chrome brookBOT
#

@shy marsh

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

shy marsh
blissful apex
#

That's the URL you paste to. When you paste it will give you a different URL with a string of random characters at the end. That will be the URL you need to share.

shy marsh
#

here

blissful apex
#

fantastic

shy marsh
#

alr

blissful apex
#

you should delete your API_KEY

shy marsh
#

from the environment?

blissful apex
#

No from the paste site

#

you just showed it to the world

#

delete it from the paste and refresh it when you get a chance

#

Otherwise somebody can steal it and use it themselves.

shy marsh
#

ohh ty for the info

blissful apex
#

You're welcome

shy marsh
#

btw it wouldnt have been a big problem as google api key is freee

#

also can u help me with the given problem

blissful apex
#

What's the problem you're having with your project?

shy marsh
#

so i have implemented ocr in my proj

#

but the problem is im not getting any errors

#

neither is the ocr working

shy marsh
blissful apex
#

have you printed out text (line 40) to see what's in it after you call the function?

#

The first step would be to figure out at what point your code isn't doing what you want it to.

shy marsh
#

for example if i take a non searchable file

#

and i upload it to my webapp

blissful apex
#

yes?

shy marsh
#

it successfull get submitted but when i ask a question from the pdf it replies with

blissful apex
#

Do you know how to implement logging in streamlit?

shy marsh
#

nooo

blissful apex
#

You can either do that to see what's happening or you need to print statements out to the console you're running it from

#

You're probably not going to see any errors printed to the web page UI itself

shy marsh
#

log_output = st.empty()

Function to capture and display logs in the Streamlit app

def log_to_streamlit(record):
log_output.text(record.getMessage())

Set the log handler to the function

logging.StreamHandler.emit = log_to_streamlit

would this be perfect??

blissful apex
#

IDK, I've never used streamlit.

shy marsh
blissful apex
#

The easier way is to use print statements in your code

shy marsh
blissful apex
#

If you print something in your code it should print something to the console you're running the app from

shy marsh
blissful apex
#

then you can trace the control flow of your program

shy marsh
#

like straight out oprint everything?

blissful apex
#

no, you put print statements in the code like I suggested above. like in a function you might do something like print("Inside function get_pdf_text")

#

So you can see how your program is flowing

#

Or like I suggested above you can do print(text) to see what's inside that variable.

shy marsh
#

so for exp take the function get_pdf_files

#

i shld just paste the above given line to get the logs of whats happening in the termina;

blissful apex
#

I don't see a get_pdf_files function

#

Did you mean get_pdf_text?

shy marsh
#

def get_pdf_text(pdf_docs):

shy marsh
blissful apex
#

ok, cool. yeah that's what I mean

blissful apex
shy marsh
#

ohh

blissful apex
#

The idea is that you are investigating your own code

shy marsh
#

so print("def get_pdf_text")

shy marsh
#

how do u know so much about python stuff

#

did u learn by doing side proj?

blissful apex
#

Yes, you learn by doing the thing over and over again.

shy marsh
#

is this correct<

#

ahh i put def

blissful apex
#

if that signifies to you that you've entered the function fine. But all you really need to do is print something like "Inside get_pdf_text". It's really up to you.

#

But if you save that then run the program again you should see that print statement every time that function gets called.

#

So if it doesn't get printed you then know that function isn't being called.

#

Do you understand?

shy marsh
#

wait lemme try

#

btw can i add u as a friend'

#

@blissful apex

shy marsh
#

@blissful apex the ocr function does gets called

chrome brookBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.