Spaces:
Sleeping
Sleeping
Hikmat Farhat
commited on
Commit
·
0e485af
1
Parent(s):
3aa55a9
put the digits in the sidebar
Browse files
app.py
CHANGED
|
@@ -7,8 +7,9 @@ import torch
|
|
| 7 |
from torchvision.datasets import MNIST
|
| 8 |
from torchvision.transforms import ToTensor
|
| 9 |
import numpy as np
|
| 10 |
-
st.title("
|
| 11 |
-
|
|
|
|
| 12 |
classifier=AutoModel.from_pretrained("hikmatfarhat/MNIST_Classifier",trust_remote_code=True)
|
| 13 |
softmax=torch.nn.Softmax(dim=1)
|
| 14 |
np.set_printoptions(precision=3,suppress=True)
|
|
@@ -16,7 +17,8 @@ imgs=[]
|
|
| 16 |
|
| 17 |
for i in range(15):
|
| 18 |
imgs.append(Image.open(f"img{i}.png"))
|
| 19 |
-
|
|
|
|
| 20 |
image=ToTensor()(image)
|
| 21 |
output=classifier(image)
|
| 22 |
output=torch.squeeze(softmax(output))
|
|
|
|
| 7 |
from torchvision.datasets import MNIST
|
| 8 |
from torchvision.transforms import ToTensor
|
| 9 |
import numpy as np
|
| 10 |
+
st.title("MNIST classifier")
|
| 11 |
+
st.markdown("This is a simple MNIST classifier using a simple neural network")
|
| 12 |
+
st.markdown("select a digit from the sidebar and the classifier will give you the probability of each digit")
|
| 13 |
classifier=AutoModel.from_pretrained("hikmatfarhat/MNIST_Classifier",trust_remote_code=True)
|
| 14 |
softmax=torch.nn.Softmax(dim=1)
|
| 15 |
np.set_printoptions(precision=3,suppress=True)
|
|
|
|
| 17 |
|
| 18 |
for i in range(15):
|
| 19 |
imgs.append(Image.open(f"img{i}.png"))
|
| 20 |
+
with st.sidebar:
|
| 21 |
+
image=image_select("select a digit",imgs,use_container_width=False)
|
| 22 |
image=ToTensor()(image)
|
| 23 |
output=classifier(image)
|
| 24 |
output=torch.squeeze(softmax(output))
|