read from bytes
Browse files- unit-test_PDFfolder.py +8 -9
unit-test_PDFfolder.py
CHANGED
|
@@ -102,23 +102,22 @@ class PdfFolder(datasets.GeneratorBasedBuilder):
|
|
| 102 |
|
| 103 |
#archive_path = archive_iterator.args[0]
|
| 104 |
|
| 105 |
-
extensions = {"
|
| 106 |
for file_path, file_obj in archive_iterator:
|
| 107 |
|
| 108 |
-
|
|
|
|
| 109 |
|
| 110 |
folder, labelset, label, filename = file_path.split("/")
|
| 111 |
if labelset != supposed_labelset:
|
| 112 |
continue
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
images = pdf2image.convert_from_bytes(file_obj.read())
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
#labels = self.info.features["labels"]
|
| 124 |
#labels.encode_example(path.parent.name.lower())
|
|
|
|
| 102 |
|
| 103 |
#archive_path = archive_iterator.args[0]
|
| 104 |
|
| 105 |
+
extensions = {"pdf", "PDF"}
|
| 106 |
for file_path, file_obj in archive_iterator:
|
| 107 |
|
| 108 |
+
if file_path.split(".")[-1] not in extensions: #metadata.jsonlines
|
| 109 |
+
continue
|
| 110 |
|
| 111 |
folder, labelset, label, filename = file_path.split("/")
|
| 112 |
if labelset != supposed_labelset:
|
| 113 |
continue
|
| 114 |
+
import pdb; pdb.set_trace() # breakpoint d40ef36a //
|
| 115 |
+
|
| 116 |
+
images = pdf2image.convert_from_bytes(file_obj.read())
|
|
|
|
|
|
|
| 117 |
|
| 118 |
+
simple = {"path": file_path, "bytes": file_obj.read(), "labels": label}
|
| 119 |
|
| 120 |
+
yield file_path, {"file": images, "labels": label}
|
| 121 |
|
| 122 |
#labels = self.info.features["labels"]
|
| 123 |
#labels.encode_example(path.parent.name.lower())
|