read from bytes
Browse files- unit-test_PDFfolder.py +12 -5
unit-test_PDFfolder.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
from typing import List
|
3 |
|
4 |
import datasets
|
@@ -98,16 +98,23 @@ class PdfFolder(datasets.GeneratorBasedBuilder):
|
|
98 |
#data/train/categoryB/581261-brown-invoice-10-29-11-04-12-2-13530037073412-pdf.pdf
|
99 |
#folder/labelset/label/filename
|
100 |
|
|
|
|
|
|
|
|
|
101 |
extensions = {".pdf", ".PDF"}
|
102 |
for file_path, file_obj in archive_iterator:
|
103 |
folder, labelset, label, filename = file_path.split("/")
|
104 |
if labelset != supposed_labelset:
|
105 |
continue
|
106 |
-
|
107 |
-
if
|
108 |
-
import pdb; pdb.set_trace() # breakpoint
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
images = pdf2image.convert_from_path(path.posix())
|
111 |
yield file_path, {"file": images, "labels": label}
|
112 |
|
113 |
#labels = self.info.features["labels"]
|
|
|
1 |
+
import os
|
2 |
from typing import List
|
3 |
|
4 |
import datasets
|
|
|
98 |
#data/train/categoryB/581261-brown-invoice-10-29-11-04-12-2-13530037073412-pdf.pdf
|
99 |
#folder/labelset/label/filename
|
100 |
|
101 |
+
#full_path = os.path.join(archive_iterator.args[0], file_path)
|
102 |
+
|
103 |
+
archive_path = archive_iterator.args[0]
|
104 |
+
|
105 |
extensions = {".pdf", ".PDF"}
|
106 |
for file_path, file_obj in archive_iterator:
|
107 |
folder, labelset, label, filename = file_path.split("/")
|
108 |
if labelset != supposed_labelset:
|
109 |
continue
|
110 |
+
|
111 |
+
if filename.split(".")[-1] in extensions:
|
112 |
+
import pdb; pdb.set_trace() # breakpoint 75999c30 //
|
113 |
+
|
114 |
+
images = pdf2image.convert_from_bytes(file_obj.read())
|
115 |
+
|
116 |
+
simple = {"path": file_path, "bytes": file_obj.read()}
|
117 |
|
|
|
118 |
yield file_path, {"file": images, "labels": label}
|
119 |
|
120 |
#labels = self.info.features["labels"]
|