0

Running the following works perfectly when I do it in my terminal

python3 number_detection.py --train_predict 'P' --file 'Images/2/_newsize_1.png'

However, I need to be able to perform this task in a different script. I'm looping through images and want to return what they're recognized as.

So running the above in the terminal works fine, but how do I translate that code to work in a different .py file?

1
  • 1
    would recommend going through modules in python. docs.python.org/3/tutorial/modules.html. Then you can organize your code and refactor the modules whenever needed. So you will import number_detection.py in your different.py file, and then call the function. Commented Apr 10, 2021 at 3:48

1 Answer 1

1

Maybe there is a way to advise you without seeing your number_detection.py file, but it would definitely allow me to give you more concrete advice if you post that.

Right now I would say, most likely you can put everything in your number_detection.py file, and turn it into a number_detection.py function that takes in your arguments

def number_detection(train_predict, file):
    #put your original code here 

Then in your image processing file,

from number_detection import number_detection

and now you can use that other function in your new file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.