Alex Strick van Linschoten commited on
Commit
02da6de
1 Parent(s): 3c4841c

update app

Browse files
Files changed (1) hide show
  1. streamlit_app.py +26 -3
streamlit_app.py CHANGED
@@ -1,8 +1,11 @@
1
- from io import BytesIO
2
  import os
3
  import pathlib
4
  import tempfile
5
  import time
 
 
 
 
6
 
7
  import fitz
8
  import gradio as gr
@@ -16,7 +19,6 @@ from icevision.all import *
16
  from icevision.models.checkpoint import *
17
  from PIL import Image as PILImage
18
 
19
-
20
  CHECKPOINT_PATH = "./allsynthetic-imgsize768.pth"
21
 
22
 
@@ -115,7 +117,7 @@ def get_pdf_document(input):
115
  f.write(uploaded_pdf.getbuffer())
116
  return fitz.open(
117
  str(pathlib.Path(filename_without_extension) / "output.pdf")
118
- )
119
 
120
 
121
  def get_image_predictions(img):
@@ -241,5 +243,26 @@ else:
241
 
242
  redaction_analysis = f"- {total_redaction_proportion}% of the total area of the redacted pages was redacted. \n- {content_redaction_proportion}% of the actual content of those redacted pages was redacted."
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  st.text(text_output + redaction_analysis)
245
  # DISPLAY IMAGES
 
1
  import os
2
  import pathlib
3
  import tempfile
4
  import time
5
+ from io import BytesIO
6
+
7
+ import pandas as pd
8
+ import altair as alt
9
 
10
  import fitz
11
  import gradio as gr
19
  from icevision.models.checkpoint import *
20
  from PIL import Image as PILImage
21
 
 
22
  CHECKPOINT_PATH = "./allsynthetic-imgsize768.pth"
23
 
24
 
117
  f.write(uploaded_pdf.getbuffer())
118
  return fitz.open(
119
  str(pathlib.Path(filename_without_extension) / "output.pdf")
120
+ )
121
 
122
 
123
  def get_image_predictions(img):
243
 
244
  redaction_analysis = f"- {total_redaction_proportion}% of the total area of the redacted pages was redacted. \n- {content_redaction_proportion}% of the actual content of those redacted pages was redacted."
245
 
246
+ source = pd.DataFrame(
247
+ {
248
+ "category": ["Unredacted", "Redacted"],
249
+ "value": [
250
+ total_redaction_proportion,
251
+ 100 - total_redaction_proportion,
252
+ ],
253
+ }
254
+ )
255
+
256
+ c = (
257
+ alt.Chart(source)
258
+ .mark_arc()
259
+ .encode(
260
+ theta=alt.Theta(field="value", type="quantitative"),
261
+ color=alt.Color(field="category", type="nominal"),
262
+ )
263
+ )
264
+
265
+ st.altair_chart(c, use_container_width=True)
266
+
267
  st.text(text_output + redaction_analysis)
268
  # DISPLAY IMAGES