chiyoi commited on
Commit
c23be95
1 Parent(s): 5b889a9
Files changed (3) hide show
  1. app.py +1 -0
  2. inference.py +2 -2
  3. model.py +4 -4
app.py CHANGED
@@ -12,6 +12,7 @@ print(f'TensorFlow {tf.__version__}')
12
 
13
  print(f'Load classifier from {config.classifier_path}')
14
  classifier = load_classifier(config)
 
15
 
16
  print('Load detector.')
17
  detector = load_detector(config)
 
12
 
13
  print(f'Load classifier from {config.classifier_path}')
14
  classifier = load_classifier(config)
15
+ classifier.summary()
16
 
17
  print('Load detector.')
18
  detector = load_detector(config)
inference.py CHANGED
@@ -26,8 +26,8 @@ def classify_action(classifier, frames, id_to_name):
26
  actions = []
27
  frames = np.array(frames)
28
  frames = tf.expand_dims(frames, 0)
29
- output = classifier(frames)
30
- confidences = tf.nn.softmax(output).numpy()[0]
31
  for (class_id, confidence) in enumerate(confidences):
32
  other_class_id = 2
33
  if confidence > 0.3 and class_id != other_class_id:
 
26
  actions = []
27
  frames = np.array(frames)
28
  frames = tf.expand_dims(frames, 0)
29
+ y = classifier(frames)
30
+ confidences = tf.squeeze(y).numpy()
31
  for (class_id, confidence) in enumerate(confidences):
32
  other_class_id = 2
33
  if confidence > 0.3 and class_id != other_class_id:
model.py CHANGED
@@ -31,10 +31,10 @@ def build_movinet(output_size, config: Config):
31
  return model
32
 
33
  def build_classifier_head(input_size, config: Config):
34
- inputs = keras.Input(shape=(input_size,))
35
- classifier = AttentionDenseClassifierHead(2, config.num_classes)(inputs)
36
- model = keras.Model(inputs=inputs, outputs=classifier)
37
- return model
38
 
39
  def build_model(movinet, classifier_head):
40
  return keras.models.Sequential([movinet, classifier_head])
 
31
  return model
32
 
33
  def build_classifier_head(input_size, config: Config):
34
+ # inputs = keras.Input(shape=(input_size,))
35
+ # classifier = AttentionDenseClassifierHead(2, config.num_classes)(inputs)
36
+ # model = keras.Model(inputs=inputs, outputs=classifier)
37
+ return keras.layers.Dense(config.num_classes, activation='softmax')
38
 
39
  def build_model(movinet, classifier_head):
40
  return keras.models.Sequential([movinet, classifier_head])