I am trying to convert few camera-clicked images of handwritten Gujarati characters to the form of MNIST dataset as I intend to pass the Gujarati handwritten characters images to the MNIST deep learning model. And as part of that, I'm trying to assign a file path to a variable named "datadir". But when executing the below code in Ubuntu 16.04, the terminal throws the error which looks like this: File "gujaratinn.py", line 7 datadir = /home/cryptoaniket256/Desktop/opencv-3.4.1/project/Resize ^ SyntaxError: invalid syntax
Note that the name of the file is gujaratinn.py and all the camera-clicked images are stored in the Resize folder.
import numpy as np
import matplotlib.pyplot as py
import os
import cv2
from pathlib import Path
datadir = Path("/home/cryptoaniket256/Desktop/opencv-
3.4.1/project/Resize")
fileToOpen = datadir/"practice.txt"
f = open(fileToOpen)
print(f.read())
os.path.dirname(__file__)to get the script's directory instead of hardcoding it.