rnmee commited on
Commit
aa1a051
·
verified ·
1 Parent(s): ce757ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -237,9 +237,11 @@ def generate_pdf_report(original_img: Image.Image, mask: np.ndarray, overlay: Im
237
  pdf.set_font("helvetica", "I", 10)
238
  pdf.cell(text="This report was generated by DR Analysis System", new_x="LMARGIN", new_y="NEXT", align='C')
239
 
240
- # Get PDF as bytes - this is the critical fix
241
- pdf_bytes = pdf.output(dest='S').encode('latin1')
242
- return pdf_bytes
 
 
243
 
244
  except Exception as e:
245
  st.error(f"PDF generation failed: {str(e)}")
@@ -325,7 +327,6 @@ def main():
325
  "image/png"
326
  )
327
 
328
- # In your main app where you create the download button:
329
  with col2:
330
  # Generate and download PDF report
331
  pdf_bytes = generate_pdf_report(
 
237
  pdf.set_font("helvetica", "I", 10)
238
  pdf.cell(text="This report was generated by DR Analysis System", new_x="LMARGIN", new_y="NEXT", align='C')
239
 
240
+ # Get PDF as bytes - the critical fix
241
+ pdf_output = pdf.output()
242
+ if isinstance(pdf_output, str):
243
+ return pdf_output.encode('latin1')
244
+ return pdf_output
245
 
246
  except Exception as e:
247
  st.error(f"PDF generation failed: {str(e)}")
 
327
  "image/png"
328
  )
329
 
 
330
  with col2:
331
  # Generate and download PDF report
332
  pdf_bytes = generate_pdf_report(