Update README.md
Browse files
README.md
CHANGED
@@ -23,19 +23,29 @@ This project is licensed under the MIT License.
|
|
23 |
|
24 |
<h1>How to use:</h1>
|
25 |
<br>
|
26 |
-
|
27 |
|
28 |
```ruby
|
29 |
-
|
|
|
30 |
import cv2
|
31 |
-
from
|
32 |
-
image=cv2.imread(image) #Load image
|
33 |
-
image=cv2.cvtColor(image, cv2.COLOR_BGR2RGB) #Convert image to RGB
|
34 |
-
image=cv2.resize(224, 224) #Default image size
|
35 |
-
model=load_model('trained_weight.h5') #Load weight
|
36 |
-
prediction=model.predict(image) #run inference
|
37 |
-
prediction=np.argmax(prediction, axis=-1) #Show highest probability class
|
38 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
<br>On Training</br>
|
40 |
```ruby
|
41 |
model=PaViT.PaViT()
|
|
|
23 |
|
24 |
<h1>How to use:</h1>
|
25 |
<br>
|
26 |
+
Import Librariese</br>
|
27 |
|
28 |
```ruby
|
29 |
+
!pip install huggingface_hub["tensorflow"]
|
30 |
+
import matplotlib.pyplot as plt
|
31 |
import cv2
|
32 |
+
from huggingface_hub import from_pretrained_keras
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
```
|
34 |
+
<h1>On inference</h1><br>
|
35 |
+
```ruby
|
36 |
+
#load model
|
37 |
+
model=from_pretrained_keras('Ajibola/PaViT')
|
38 |
+
|
39 |
+
#load image
|
40 |
+
image=cv2.imread('image_path')
|
41 |
+
image=cv2.resize(image, (224, 224)) #224 is the default image size
|
42 |
+
image=image.image.max() #Normalize the image to [0-1]
|
43 |
+
prediction=model.predict(image)
|
44 |
+
prediction=np.argmax(prediction, axis=-1) #Get Highest probability class
|
45 |
+
|
46 |
+
|
47 |
+
```
|
48 |
+
|
49 |
<br>On Training</br>
|
50 |
```ruby
|
51 |
model=PaViT.PaViT()
|