File size: 850 Bytes
d7b463f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438b071
d7b463f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
license: unknown
metrics:
- accuracy
pipeline_tag: image-classification
tags:
- fin
- image
---


## Download model

```bash
git lfs install
git clone https://huggingface.co/Abner0803/multiclass-stock-cnn
```

## Usage

In directory `./multiclass-stock-cnn`, you can try the pre-trained model out

```bash
touch expr.py

pip install torch pillow numpy
```

```python
## expr.py

import torch
import numpy as np
from PIL import Image


image_file = "temp.png"
matrix = np.array(Image.open(image_file))
tensor = torch.Tensor(matrix, dtype=torch.float32)

pred = model(tensor.unsqueeze(0).unsqueeze(0))

print(pred)
```

You'll get the probability of each class

```bash
tensor([[9.9691e-01, 1.1429e-09, 3.4367e-20, 6.5349e-30, 9.6665e-25, 1.1544e-27,
         2.8234e-11, 6.8401e-21, 2.1943e-16, 3.0882e-03]],
       grad_fn=<SoftmaxBackward0>)
```