Spaces:
Runtime error
Runtime error
Alex Strick van Linschoten
commited on
Commit
•
54f6682
1
Parent(s):
422c318
update orientation handling
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import fitz
|
|
7 |
import tempfile
|
8 |
import os
|
9 |
from fpdf import FPDF
|
|
|
10 |
|
11 |
learn = load_learner(
|
12 |
hf_hub_download("strickvl/redaction-classifier-fastai", "model.pkl")
|
@@ -50,7 +51,12 @@ def predict(pdf, confidence, generate_file):
|
|
50 |
[i for i in os.listdir(tmp_dir) if i.endswith("png")]
|
51 |
)
|
52 |
for image in imagelist:
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
# pdf.image(os.path.join(tmp_dir, image), w=190, h=280)
|
55 |
pdf.image(os.path.join(tmp_dir, image))
|
56 |
pdf.output(report, "F")
|
|
|
7 |
import tempfile
|
8 |
import os
|
9 |
from fpdf import FPDF
|
10 |
+
from PIL import Image as PILImage
|
11 |
|
12 |
learn = load_learner(
|
13 |
hf_hub_download("strickvl/redaction-classifier-fastai", "model.pkl")
|
|
|
51 |
[i for i in os.listdir(tmp_dir) if i.endswith("png")]
|
52 |
)
|
53 |
for image in imagelist:
|
54 |
+
with PILImage.open(os.path.join(tmp_dir, image)) as img:
|
55 |
+
size = img.size
|
56 |
+
if size[0] > size[1]:
|
57 |
+
pdf.add_page("L")
|
58 |
+
else:
|
59 |
+
pdf.add_page("P")
|
60 |
# pdf.image(os.path.join(tmp_dir, image), w=190, h=280)
|
61 |
pdf.image(os.path.join(tmp_dir, image))
|
62 |
pdf.output(report, "F")
|