mgspl commited on
Commit
cff1408
1 Parent(s): f12ccde

Update app.py with new model , update desc

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -14,9 +14,9 @@ class Flatten(nn.Module):
14
  class ConvNet(nn.Module):
15
  def __init__(self):
16
  super(ConvNet, self).__init__()
17
- self.conv1 = nn.Conv2d(1, 32, kernel_size=5, stride=2, padding=1)
18
- self.conv2 = nn.Conv2d(32, 32, kernel_size=5, stride=2, padding=1)
19
- self.conv3 = nn.Conv2d(32, 10, kernel_size=5, stride=2, padding=1)
20
  self.fc = nn.Linear(10,10)
21
  self.dropout = nn.Dropout(0.5)
22
  self.avgpool = nn.AdaptiveAvgPool2d(1)
@@ -50,7 +50,7 @@ def predict(img, withGradio=False):
50
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
 
52
  # Get the state_dict of conv_net
53
- state_dict = torch.load('model-e2e-v6-1-13092023.pth')
54
 
55
  # Define a new state_dict for ConvNet
56
  new_state_dict = OrderedDict()
@@ -86,8 +86,8 @@ def wrapper_fn(input_image):
86
  return predict(input_image, withGradio=True)
87
 
88
  # Define Gradio interface
89
- title = "MNIST - understanding the basis"
90
- description = "I have created and trained a custom neural network for MNIST. The score of `valid loss 0.126034` isn't the optimal one but it is reasonably acceptable. This is an exercise project where I only allowed myself a limited time to improve the result. You need to use same size image as the model 28x28, white text on black for best results."
91
  examples = ['data/0-custom-invert.jpg', 'data/0.jpg', 'data/2.jpg', 'data/3.jpg', 'data/5.jpg', 'data/9.jpg', 'data/0-custom.jpg',]
92
  output = gr.Textbox(label="Output prediction")
93
  app = gr.Interface(fn=wrapper_fn, inputs=gr.Image(), outputs=output, title=title,description=description,examples=examples)
 
14
  class ConvNet(nn.Module):
15
  def __init__(self):
16
  super(ConvNet, self).__init__()
17
+ self.conv1 = nn.Conv2d(1, 64, kernel_size=5, stride=2, padding=1)
18
+ self.conv2 = nn.Conv2d(64, 64, kernel_size=5, stride=2, padding=1)
19
+ self.conv3 = nn.Conv2d(64, 10, kernel_size=5, stride=2, padding=1)
20
  self.fc = nn.Linear(10,10)
21
  self.dropout = nn.Dropout(0.5)
22
  self.avgpool = nn.AdaptiveAvgPool2d(1)
 
50
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
 
52
  # Get the state_dict of conv_net
53
+ state_dict = torch.load('this-is-mnist-model-f1c-desk-19092023.pth')
54
 
55
  # Define a new state_dict for ConvNet
56
  new_state_dict = OrderedDict()
 
86
  return predict(input_image, withGradio=True)
87
 
88
  # Define Gradio interface
89
+ title = "MNIST - understanding the basics"
90
+ description = "I have created and trained a CNN for MNIST. You can find the exercise notebook [here](https://www.kaggle.com/code/mindgspl/exercise-mnist). Note : use same size image as the model 28x28, white text on black for best results. "
91
  examples = ['data/0-custom-invert.jpg', 'data/0.jpg', 'data/2.jpg', 'data/3.jpg', 'data/5.jpg', 'data/9.jpg', 'data/0-custom.jpg',]
92
  output = gr.Textbox(label="Output prediction")
93
  app = gr.Interface(fn=wrapper_fn, inputs=gr.Image(), outputs=output, title=title,description=description,examples=examples)