nicholasKluge commited on
Commit
b41d93e
1 Parent(s): 83bfd92

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -39
README.md CHANGED
@@ -3,42 +3,49 @@ library_name: keras
3
  tags:
4
  - Image Classification
5
  ---
6
-
7
- ## Model description
8
-
9
- More information needed
10
-
11
- ## Intended uses & limitations
12
-
13
- More information needed
14
-
15
- ## Training and evaluation data
16
-
17
- More information needed
18
-
19
- ## Training procedure
20
-
21
- ### Training hyperparameters
22
-
23
- The following hyperparameters were used during training:
24
-
25
- | Hyperparameters | Value |
26
- | :-- | :-- |
27
- | name | Adam |
28
- | learning_rate | 0.0010000000474974513 |
29
- | decay | 0.0 |
30
- | beta_1 | 0.8999999761581421 |
31
- | beta_2 | 0.9990000128746033 |
32
- | epsilon | 1e-07 |
33
- | amsgrad | False |
34
- | training_precision | float32 |
35
-
36
-
37
- ## Model Plot
38
-
39
- <details>
40
- <summary>View Model Plot</summary>
41
-
42
- ![Model Image](./model.png)
43
-
44
- </details>
 
 
 
 
 
 
 
 
3
  tags:
4
  - Image Classification
5
  ---
6
+ # Cifar-CNN (Teeny-Tiny Castle)
7
+
8
+ This model is part of a tutorial tied to the [Teeny-Tiny Castle](https://github.com/Nkluge-correa/TeenyTinyCastle), an open-source repository containing educational tools for AI Ethics and Safety research.
9
+
10
+ ## How to Use
11
+
12
+ ```python
13
+ import numpy as np
14
+ import tensorflow as tf
15
+ import matplotlib.pyplot as plt
16
+ from huggingface_hub import from_pretrained_keras
17
+
18
+ # Download the CIFAR-10 dataset
19
+ (x_train, y_train), (x_test, y_test)  = tf.keras.datasets.cifar10.load_data()
20
+
21
+ class_names = ['Airplane', 'Automobile', 'Bird', 'Cat', 'Deer',
22
+                'Dog', 'Frog', 'Horse', 'Ship', 'Truck']
23
+
24
+ plt.figure(figsize=[10, 10])
25
+ for i in range(25):
26
+ plt.subplot(5, 5, i+1)
27
+ plt.xticks([])
28
+ plt.yticks([])
29
+ plt.grid(False)
30
+ plt.imshow(x_test[i], cmap=plt.cm.binary)
31
+ plt.xlabel(class_names[y_test[i][0]])
32
+
33
+ plt.show()
34
+
35
+ # Load the model from the Hub
36
+ model = from_pretrained_keras("AiresPucrs/Cifar-CNN")
37
+ model.compile(
38
+     loss=tf.keras.losses.CategoricalCrossentropy(),
39
+     metrics=['categorical_accuracy']
40
+ )
41
+ x_train = x_train.astype('float32')
42
+ x_train = x_train / 255.
43
+ y_train = tf.keras.utils.to_categorical(y_train, 10)
44
+ x_test = x_test.astype('float32')
45
+ x_test = x_test / 255.
46
+ y_test = tf.keras.utils.to_categorical(y_test, 10)
47
+ test_loss_score, test_acc_score = model.evaluate(x_test, y_test, verbose=0)
48
+ model.summary()
49
+ print(f'Loss: {round(test_loss_score, 2)}.')
50
+ print(f'Accuracy: {round(test_acc_score * 100, 2)} %.')
51
+ ```