Devmurari commited on
Commit
d7f7f68
·
1 Parent(s): d9c78ae

experiment

Browse files
Files changed (1) hide show
  1. app.py +50 -1
app.py CHANGED
@@ -3,8 +3,57 @@ from tensorflow.keras.models import load_model
3
  import gradio as gr
4
  import numpy as np
5
  import cv2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- model = load_model("model_1.h5")
8
 
9
  labels = ["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thrteen","fourteen","fifteen","sixteen","seventeen","eightteen","nineteen"]
10
 
 
3
  import gradio as gr
4
  import numpy as np
5
  import cv2
6
+ import numpy as np
7
+ import os
8
+ import sys
9
+ from tensorflow import keras
10
+ from tensorflow.keras import layers
11
+
12
+ EPOCHS = 10
13
+ IMG_WIDTH = 30
14
+ IMG_HEIGHT = 30
15
+ NUM_CATEGORIES = 43
16
+ TEST_SIZE = 0.4
17
+
18
+ def get_model():
19
+ """
20
+ Returns a compiled convolutional neural network model. Assume that the
21
+ `input_shape` of the first layer is `(IMG_WIDTH, IMG_HEIGHT, 3)`.
22
+ The output layer should have `NUM_CATEGORIES` units, one for each category.
23
+ """
24
+ # Experimenting with different architectures of a Sequential model and this is so far best for me
25
+ # Accepts input with shape of (30, 30, 3)
26
+ # Convolutional layer with 65 filters and relu activation function
27
+ # Maxpooled by (2, 2) kernel
28
+ # Second convolutional layer with higher number of filter i.e 256 and relu activation function
29
+ # Flattering nd shape and Dense layer with 450 nuerons and relu activation funtion
30
+ # Output layer with 43 nuerons and softmax activation function
31
+
32
+ model = tf.keras.Sequential([
33
+ layers.Conv2D(64, 5, input_shape = (30, 30, 3), name = "conv1", activation="relu"),
34
+ layers.MaxPool2D((2, 2), name = "pool1"),
35
+ layers.Conv2D(256, 3, name = "conv2", activation="relu"),
36
+ layers.MaxPool2D((2, 2), name = "pool2"),
37
+ layers.Flatten(),
38
+ layers.Dense(450, activation = "relu", name = "dense1"),
39
+ layers.Dense(NUM_CATEGORIES-1, activation = "softmax", name = "output")
40
+ ])
41
+
42
+ # Printing model summary and compiling with adam algorithm, categorical_crossentropy as 43 output neurons
43
+ model.summary()
44
+
45
+ model.compile(
46
+ optimizer = "adam",
47
+ loss = "categorical_crossentropy",
48
+ metrics=["accuracy"]
49
+ )
50
+
51
+ return model
52
+
53
+ # model = load_model("best_traffic_model.h5")
54
+ # model.compile(optimizer="adam", loss="categorical_crossentropy")
55
 
56
+ model = get_model()
57
 
58
  labels = ["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thrteen","fourteen","fifteen","sixteen","seventeen","eightteen","nineteen"]
59