Abner0803 commited on
Commit
d7b463f
·
verified ·
1 Parent(s): f292e32

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -3
README.md CHANGED
@@ -1,3 +1,52 @@
1
- ---
2
- license: unknown
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: unknown
3
+ metrics:
4
+ - accuracy
5
+ pipeline_tag: image-classification
6
+ tags:
7
+ - fin
8
+ - image
9
+ ---
10
+
11
+
12
+ ## Download model
13
+
14
+ ```bash
15
+ git lfs install
16
+ git clone https://huggingface.co/Abner0803/multiclass-stock-cnn
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ In directory `./multiclass-stock-cnn', you can try the pre-trained model out
22
+
23
+ ```bash
24
+ touch expr.py
25
+
26
+ pip install torch pillow numpy
27
+ ```
28
+
29
+ ```python
30
+ ## expr.py
31
+
32
+ import torch
33
+ import numpy as np
34
+ from PIL import Image
35
+
36
+
37
+ image_file = "temp.png"
38
+ matrix = np.array(Image.open(image_file))
39
+ tensor = torch.Tensor(matrix, dtype=torch.float32)
40
+
41
+ pred = model(tensor.unsqueeze(0).unsqueeze(0))
42
+
43
+ print(pred)
44
+ ```
45
+
46
+ You'll get the probability of each class
47
+
48
+ ```bash
49
+ tensor([[9.9691e-01, 1.1429e-09, 3.4367e-20, 6.5349e-30, 9.6665e-25, 1.1544e-27,
50
+ 2.8234e-11, 6.8401e-21, 2.1943e-16, 3.0882e-03]],
51
+ grad_fn=<SoftmaxBackward0>)
52
+ ```