Spaces:
Runtime error
Runtime error
Laks Srini
commited on
Commit
·
beb11ab
1
Parent(s):
873f31f
Upload latest models, conv vs, swin
Browse files- app.py +20 -7
- model.pkl → model_conv.pkl +2 -2
- model_swin.pkl +2 -2
app.py
CHANGED
@@ -10,21 +10,34 @@ import gradio as gr
|
|
10 |
# def is_cat(x): return x[0].isupper()
|
11 |
|
12 |
# %% app.ipynb 3
|
13 |
-
|
|
|
14 |
|
15 |
# %% app.ipynb 5
|
16 |
-
categories = [
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
return dict(zip(categories, map(float, probs)))
|
21 |
|
22 |
|
23 |
# %% app.ipynb 7
|
24 |
-
image = gr.inputs.Image(shape=(
|
25 |
label = gr.outputs.Label()
|
26 |
examples = ["kitchen.jpg", "living_room.jpg", "living_room2.jpg"]
|
27 |
|
28 |
-
intf = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
intf.launch(inline=False)
|
30 |
|
|
|
10 |
# def is_cat(x): return x[0].isupper()
|
11 |
|
12 |
# %% app.ipynb 3
|
13 |
+
learn_swin = load_learner("model_swin.pkl")
|
14 |
+
learn_conv = load_learner("model_conv.pkl")
|
15 |
|
16 |
# %% app.ipynb 5
|
17 |
+
categories = [
|
18 |
+
'Bathroom', 'Bedroom', 'Floor plan', 'Front', 'Home Office', 'Kitchen',
|
19 |
+
'Laundry', 'Living room', 'Parking', 'Porch', 'Swimming pool', 'Views',
|
20 |
+
'Walk In Closet', 'Yard'
|
21 |
+
]
|
22 |
+
|
23 |
+
def classify_img(img, use_conv):
|
24 |
+
pred,idx,probs = learn_conv.predict(img) if use_conv else learn_swin.predict(img)
|
25 |
return dict(zip(categories, map(float, probs)))
|
26 |
|
27 |
|
28 |
# %% app.ipynb 7
|
29 |
+
image = gr.inputs.Image(shape=(240, 320))
|
30 |
label = gr.outputs.Label()
|
31 |
examples = ["kitchen.jpg", "living_room.jpg", "living_room2.jpg"]
|
32 |
|
33 |
+
intf = gr.Interface(
|
34 |
+
fn=classify_img,
|
35 |
+
inputs=[
|
36 |
+
gr.components.Image(type="pil", shape=(640, 480)),
|
37 |
+
gr.components.Checkbox(label="Use conv model", value=False),
|
38 |
+
],
|
39 |
+
outputs=label,
|
40 |
+
examples=examples
|
41 |
+
)
|
42 |
intf.launch(inline=False)
|
43 |
|
model.pkl → model_conv.pkl
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ebe165e9dfd2333810ae84c91e84dcce5ea0522cc9dae1c7c1155a2a4a0835e8
|
3 |
+
size 791581993
|
model_swin.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3558ca78c5c2ca865380f05c99cc777081a5eb765cd8ab286d6a74e4dd981cd
|
3 |
+
size 797927745
|