Spaces:
Sleeping
Sleeping
=
commited on
Commit
β’
c2fc618
1
Parent(s):
12bc61f
Fixed
Browse files- .vscode/settings.json +17 -0
- README.md +4 -11
- app.py +8 -7
- requirements.txt +2 -1
.vscode/settings.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"workbench.colorCustomizations": {
|
3 |
+
"activityBar.activeBackground": "#4f6f14",
|
4 |
+
"activityBar.background": "#4f6f14",
|
5 |
+
"activityBar.foreground": "#e7e7e7",
|
6 |
+
"activityBar.inactiveForeground": "#e7e7e799",
|
7 |
+
"activityBarBadge.background": "#0f3a51",
|
8 |
+
"activityBarBadge.foreground": "#e7e7e7",
|
9 |
+
"sash.hoverBorder": "#4f6f14",
|
10 |
+
"statusBar.background": "#30440c",
|
11 |
+
"statusBar.foreground": "#e7e7e7",
|
12 |
+
"statusBarItem.hoverBackground": "#4f6f14",
|
13 |
+
"statusBarItem.remoteBackground": "#30440c",
|
14 |
+
"statusBarItem.remoteForeground": "#e7e7e7"
|
15 |
+
},
|
16 |
+
"peacock.color": "#30440c"
|
17 |
+
}
|
README.md
CHANGED
@@ -1,13 +1,6 @@
|
|
1 |
-
|
2 |
-
title: Pizza NotPizza
|
3 |
emoji: π
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk:
|
7 |
-
sdk_version: 1.10.0
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
10 |
-
license: openrail
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
title: Pizza Not Pizza
|
|
|
2 |
emoji: π
|
3 |
+
colorFrom: red
|
4 |
+
colorTo: yellow
|
5 |
+
sdk: docker
|
|
|
|
|
6 |
pinned: false
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
from read import classify
|
6 |
|
7 |
st.title("Pizza & Not Pizza")
|
8 |
|
9 |
-
device = torch.device("cpu")
|
10 |
-
checkpoint = torch.load(
|
11 |
-
model = checkpoint[
|
12 |
-
classes = checkpoint[
|
13 |
-
tran = checkpoint[
|
14 |
|
15 |
# upload image
|
16 |
while True:
|
@@ -19,13 +20,13 @@ while True:
|
|
19 |
|
20 |
if uploaded_file is not None:
|
21 |
img = Image.open(uploaded_file)
|
22 |
-
st.image(img, caption=
|
23 |
label = classify(model, img, tran, classes, device)
|
24 |
st.write(label)
|
25 |
|
26 |
elif taking_picture is not None:
|
27 |
img = Image.open(taking_picture)
|
28 |
-
st.image(img, caption=
|
29 |
label = classify(model, img, tran, classes, device)
|
30 |
st.write(label)
|
31 |
|
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
+
import os
|
5 |
|
6 |
from read import classify
|
7 |
|
8 |
st.title("Pizza & Not Pizza")
|
9 |
|
10 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
11 |
+
checkpoint = torch.load(os.path.join(os.getcwd(), "best.pth.tar"))
|
12 |
+
model = checkpoint["model"]
|
13 |
+
classes = checkpoint["classes"]
|
14 |
+
tran = checkpoint["transform"]
|
15 |
|
16 |
# upload image
|
17 |
while True:
|
|
|
20 |
|
21 |
if uploaded_file is not None:
|
22 |
img = Image.open(uploaded_file)
|
23 |
+
st.image(img, caption="Uploaded Image.", use_column_width=True)
|
24 |
label = classify(model, img, tran, classes, device)
|
25 |
st.write(label)
|
26 |
|
27 |
elif taking_picture is not None:
|
28 |
img = Image.open(taking_picture)
|
29 |
+
st.image(img, caption="Uploaded Image.", use_column_width=True)
|
30 |
label = classify(model, img, tran, classes, device)
|
31 |
st.write(label)
|
32 |
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
-
|
2 |
torch
|
3 |
torchvision
|
|
|
|
1 |
+
pillow
|
2 |
torch
|
3 |
torchvision
|
4 |
+
streamlit
|