|
--- |
|
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>) |
|
``` |