Alex Strick van Linschoten commited on
Commit
abe0fc0
1 Parent(s): 2db4764

let's deploy to huggingface spaces

Browse files
Files changed (8) hide show
  1. app.py +40 -0
  2. model.pkl +3 -0
  3. requirements.txt +2 -0
  4. test1.jpg +0 -0
  5. test2.jpg +0 -0
  6. test3.jpg +0 -0
  7. test4.jpg +0 -0
  8. test5.jpg +0 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ imported_learn = load_learner("model.pkl")
6
+
7
+ labels = learn.dls.vocab
8
+
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred, pred_idx, probs = learn.predict(img)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+
16
+ title = "Redacted Document Classifier"
17
+ description = "A classifier trained on publicly released redacted (and unredacted) FOIA documents, using fastai."
18
+ article = "<p style='text-align: center'><a href='https://mlops.systems/fastai/redactionmodel/computervision/datalabelling/2021/09/06/redaction-classification-chapter-2.html' target='_blank'>Blog post</a></p>"
19
+ examples = [
20
+ "test1.jpg",
21
+ "test2.jpg",
22
+ "test3.jpg",
23
+ "test4.jpg",
24
+ "test5.jpg",
25
+ ]
26
+ interpretation = "default"
27
+ # interpretation='shap'
28
+ enable_queue = True
29
+
30
+ gr.Interface(
31
+ fn=predict,
32
+ inputs=gr.inputs.Image(shape=(512, 512)),
33
+ outputs=gr.outputs.Label(num_top_classes=3),
34
+ title=title,
35
+ description=description,
36
+ article=article,
37
+ examples=examples,
38
+ interpretation=interpretation,
39
+ enable_queue=enable_queue,
40
+ ).launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1f259b0d96a72e65b72fea92226109aebf275adeec7e1dcddda00e8cb5b8ec7
3
+ size 87538219
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
test1.jpg ADDED
test2.jpg ADDED
test3.jpg ADDED
test4.jpg ADDED
test5.jpg ADDED