-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (23 loc) · 914 Bytes
/
main.py
File metadata and controls
35 lines (23 loc) · 914 Bytes
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
from PIL import Image
import pytesseract
import csv
import os
import test
pathname = 'C:\\Users\\Shaurya Agarwal\\Documents\\HackathonProject\\MemeTagging\\test_images'
filenamelist = os.listdir(pathname)
lines = [["FilePath", "Tags", "MemeTemplate"]]
file_ext = [".png", ".jpeg", ".jpg"]
for imagename in filenamelist:
for file_ext_name in file_ext:
if file_ext_name in imagename:
filename = pathname + "\\" + imagename
text = pytesseract.image_to_string(Image.open(filename))
text = text.replace("\n", " ")
x = test.ret_strClassification(filename)
lines.append([filename, text, x])
with open('memetags.csv', 'w') as writeFile:
writer = csv.writer(writeFile)
writer.writerows(lines)
writeFile.close()
def ret_dirPath():
return pathname