Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,6 +47,11 @@ def detect_construction_info(caption):
|
|
47 |
def generate_dpr(files):
|
48 |
dpr_text = []
|
49 |
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
|
|
|
|
|
50 |
for file in files:
|
51 |
# Open the image from file path
|
52 |
image = Image.open(file.name) # Using file.name for filepath
|
@@ -63,7 +68,7 @@ def generate_dpr(files):
|
|
63 |
detailed_caption = detect_construction_info(caption)
|
64 |
|
65 |
# Generate DPR section for this image
|
66 |
-
dpr_section = f"
|
67 |
dpr_text.append(dpr_section)
|
68 |
|
69 |
# Generate a PDF report
|
@@ -72,7 +77,7 @@ def generate_dpr(files):
|
|
72 |
c.drawString(100, 750, "Daily Progress Report")
|
73 |
c.drawString(100, 730, f"Generated on: {current_time}")
|
74 |
|
75 |
-
# Add the
|
76 |
y_position = 700
|
77 |
for section in dpr_text:
|
78 |
c.drawString(100, y_position, section)
|
|
|
47 |
def generate_dpr(files):
|
48 |
dpr_text = []
|
49 |
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
50 |
+
|
51 |
+
# Add header to the PDF
|
52 |
+
dpr_text.append(f"Daily Progress Report\nGenerated on: {current_time}\n")
|
53 |
+
|
54 |
+
# Process each uploaded file (image)
|
55 |
for file in files:
|
56 |
# Open the image from file path
|
57 |
image = Image.open(file.name) # Using file.name for filepath
|
|
|
68 |
detailed_caption = detect_construction_info(caption)
|
69 |
|
70 |
# Generate DPR section for this image
|
71 |
+
dpr_section = f"\nImage: {file.name}\n{detailed_caption}\n"
|
72 |
dpr_text.append(dpr_section)
|
73 |
|
74 |
# Generate a PDF report
|
|
|
77 |
c.drawString(100, 750, "Daily Progress Report")
|
78 |
c.drawString(100, 730, f"Generated on: {current_time}")
|
79 |
|
80 |
+
# Add the detailed captions for each image to the PDF
|
81 |
y_position = 700
|
82 |
for section in dpr_text:
|
83 |
c.drawString(100, y_position, section)
|