compendious commited on
Commit
6042735
·
verified ·
1 Parent(s): 72ebe85

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. backend/app.py +1 -1
  3. backend/model.py +5 -0
  4. frontend/index.html +2 -1
README.md CHANGED
@@ -12,7 +12,7 @@ app_port: 7860
12
 
13
  Use the tool live [here](https://ocr.varak.dev).
14
 
15
- This is an optical character recognition (OCR) tool that extracts characters from drawings. Using basic JS/HTML, we create a canvas to draw on, convert the drawing toa usable 28x28 pixel format, and send to the backend for prediction. In the backend, we use FastAPI to handle requests, with the only routes being `\` for the home page and `\predict` for predictions. The prediction route uses a pre-trained CNN model that is able to recognize all English characters and digits. For more details on the architecture, the dataset, and training process, check out [this writeup](https://github.com/intelligent-username/CNN/tree/main/char), which presents the simpler of two models trained for my writeup on CNNs (this one).
16
 
17
  ## Usage
18
 
 
12
 
13
  Use the tool live [here](https://ocr.varak.dev).
14
 
15
+ This is an optical character recognition (OCR) tool that extracts characters from drawings. Using basic JS/HTML, we create a canvas to draw on, convert the drawing toa usable 28x28 pixel format, and send to the backend for prediction. In the backend, we use FastAPI to handle requests, with the only routes being `/` for the home page and `/predict` for predictions. The prediction route uses a pre-trained CNN model that is able to recognize all English characters and digits. For more details on the architecture, the dataset, and training process, check out [this writeup](https://github.com/intelligent-username/CNN/tree/main/char), which presents the simpler of two models trained for my writeup on CNNs (this one). For a better understanding of CNNs in general, check out this [broader writeup](https://github.com/intelligent-username/CNN).
16
 
17
  ## Usage
18
 
backend/app.py CHANGED
@@ -41,7 +41,7 @@ print(f"Server running on: {device}")
41
  # MODEL DOWNLOAD
42
 
43
  # 1. Setup paths
44
- REPO_ID = "compendious/EMNIST-OCR-WEIGHTS/"
45
  FILENAME = "EMNIST_CNN.pth"
46
 
47
  # NOTE: If I ever make this repo private, I need to add authentication tokens to hf_hub_download calls.
 
41
  # MODEL DOWNLOAD
42
 
43
  # 1. Setup paths
44
+ REPO_ID = "compendious/EMNIST-OCR-WEIGHTS"
45
  FILENAME = "EMNIST_CNN.pth"
46
 
47
  # NOTE: If I ever make this repo private, I need to add authentication tokens to hf_hub_download calls.
backend/model.py CHANGED
@@ -3,6 +3,11 @@ VGG-style CNN for EMNIST character classification.
3
  See the README for a better description.
4
  """
5
 
 
 
 
 
 
6
  import torch
7
  import torch.nn as nn
8
  import torch.nn.functional as F
 
3
  See the README for a better description.
4
  """
5
 
6
+ # The .pth file (weights) for this model will be downloaded from HuggingFace by app.py
7
+ # It's hosted at https://huggingface.co/compendious/EMNIST-OCR-WEIGHTS/
8
+ # The file is EMNIST_CNN.pth
9
+ # Go here to download directly: https://huggingface.co/compendious/EMNIST-OCR-WEIGHTS/resolve/main/EMNIST_CNN.pth?download=true
10
+
11
  import torch
12
  import torch.nn as nn
13
  import torch.nn.functional as F
frontend/index.html CHANGED
@@ -35,7 +35,7 @@
35
  </div>
36
  </section>
37
 
38
- <!-- Right side reserved for predictions-->
39
  <section class="prediction-section">
40
  <h2>Predictions</h2>
41
  <canvas
@@ -50,6 +50,7 @@
50
  </section>
51
  </main>
52
 
 
53
  <script src="/static/helpers/barGraphs.js"></script>
54
  <script src="/static/helpers/Sanitizer.js"></script>
55
  <script src="/static/helpers/kSlider.js"></script>
 
35
  </div>
36
  </section>
37
 
38
+ <!-- Right: Predictions Canvas-->
39
  <section class="prediction-section">
40
  <h2>Predictions</h2>
41
  <canvas
 
50
  </section>
51
  </main>
52
 
53
+ <!-- Import everything else -->
54
  <script src="/static/helpers/barGraphs.js"></script>
55
  <script src="/static/helpers/Sanitizer.js"></script>
56
  <script src="/static/helpers/kSlider.js"></script>