LT8 commited on
Commit
115d230
·
1 Parent(s): 9eac1c9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -43
README.md CHANGED
@@ -2,7 +2,8 @@
2
  license: creativeml-openrail-m
3
  ---
4
 
5
- Based on:
 
6
  ```
7
  ETL8B
8
  - 153916 samples
@@ -12,47 +13,39 @@ ETL8B
12
  - image_height: 63px
13
  ```
14
 
15
- I was testing a few more samples locally with the below. Note the results of the model are encoded.
16
-
17
-
18
- ```
19
-
20
- from PIL import Image
21
- import numpy as np
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  import torch
23
-
24
- # Define the preprocessing function
25
- def preprocess_image(image_path):
26
- image = Image.open(image_path).convert('L')
27
- resized_image = image.resize((64, 64))
28
- image_array = np.array(resized_image) / 255.0
29
- reshaped_image = image_array.reshape(1, -1)
30
- return reshaped_image
31
-
32
- # Function to predict a label for an image using your PyTorch model
33
- def predict_label(image_path, model, device):
34
- # Convert the preprocessed image to torch tensor and send to the device
35
- processed_image = torch.tensor(preprocess_image(image_path), dtype=torch.float32).to(device)
36
-
37
- # Predict the label using the model
38
- with torch.no_grad():
39
- outputs = model(processed_image)
40
- _, predicted_class = torch.max(outputs.data, 1)
41
-
42
- return predicted_class.item()
43
-
44
- # Create the reverse dictionary for decoding
45
- index_to_label = {index: label for label, index in label_to_index.items()}
46
-
47
- # Test using a sample image
48
- sample_image_path = ["D:\ETL8G\\0x4e2d\\012780.png", "D:\ETL8G\\0x5e0c\\078406.png", "D:\ETL8G\\0x6d41\\130205.png", "D:\ETL8G\\0x7a40\\046207.png", "D:\ETL8G\\0x7b56\\024793.png"]
49
-
50
- for sample in sample_image_path:
51
- predicted_encoded_label = predict_label(sample, model, device)
52
-
53
- # Decode the predicted label using the reversed dictionary
54
- decoded_label = index_to_label[predicted_encoded_label]
55
- print(f"The model predicts the image label as: {decoded_label}")
56
-
57
-
58
  ```
 
2
  license: creativeml-openrail-m
3
  ---
4
 
5
+ # Model Card for Kanji_ETL8G
6
+ ### Summary:
7
  ```
8
  ETL8B
9
  - 153916 samples
 
13
  - image_height: 63px
14
  ```
15
 
16
+ ## Model Details
17
+ - **Model Name:** Kanji_ETL8G
18
+ - **Version:** 1.0.0
19
+ - **Model Type:** Neural Network
20
+ - **Framework:** PyTorch
21
+
22
+ ## Model Description
23
+ This model is trained on a dataset derived from the ETL8G dataset to recognize Kanji characters from 64x64 grayscale images. The primary use-case is for optical character recognition (OCR) for handwritten Kanji characters.
24
+
25
+ ## Intended Use
26
+ The primary application of this model is for OCR tasks to recognize handwritten Kanji characters in images, with potential extensions for applications like smart dictionary lookup, handwriting-based user authentication, and so on.
27
+
28
+ ## Limitations
29
+ This model might have limitations regarding:
30
+ - Variability in handwriting styles not present in the training set. (161 samples per character/class were used)
31
+ - Noises and artifacts in input images.
32
+ - Characters written in unconventional ways.
33
+ ## Data Details
34
+ ### Training Data:
35
+ - **Dataset:** Derived from the ETL8G dataset (hhttp://etlcdb.db.aist.go.jp/specification-of-etl-8)
36
+ - **Size:** 153916 samples
37
+ - **Data Type:** 64x64 grayscale images of handwritten Kanji characters
38
+ - **Labels:** 956 unique characters (classes)
39
+ ## Model Files
40
+ - **PyTorch Model:** Kanji_ETL8G.pth
41
+ - **ONNX Model:** Kanji_ETL8G.onnx
42
+ - **CoreML Model:** next effort....
43
+ ## Usage
44
+ ```python
45
  import torch
46
+ model = torch.load('Kanji_ETL8G.pth')
47
+ model.eval()
48
+ # Assuming input image tensor is `input_tensor`
49
+ output = model(input_tensor)
50
+ predicted_label = torch.argmax(output).item()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ```