noahzhy commited on
Commit
c393f6b
1 Parent(s): e4ab6aa

Update TFliteDemo constructor parameters and model.tflite file

Browse files
app.py CHANGED
@@ -69,7 +69,7 @@ def load_dict(dict_path='label.names'):
69
 
70
 
71
  class TFliteDemo:
72
- def __init__(self, model_path, blank=68, conf_mode="mean"):
73
  self.blank = blank
74
  self.conf_mode = conf_mode
75
  self.interpreter = tf.lite.Interpreter(model_path=model_path)
@@ -91,14 +91,15 @@ class TFliteDemo:
91
  raise ValueError('img is None')
92
  image = img.copy()
93
  image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
94
- image = center_fit(image, 128, 64, top_left=True)
95
- image = np.reshape(image, (1, *image.shape, 1)).astype(np.uint8)
96
  return image
97
 
98
  def get_confidence(self, pred, mode="mean"):
99
  _argmax = np.argmax(pred, axis=-1)
100
  _idx = _argmax != pred.shape[-1] - 1
101
- conf = pred[_idx, _argmax[_idx]] / 255.0
 
102
  return np.min(conf) if mode == "min" else np.mean(conf)
103
 
104
  def postprocess(self, pred):
@@ -125,7 +126,7 @@ if __name__ == '__main__':
125
  </div>
126
  '''
127
  # init model
128
- demo = TFliteDemo(os.path.join(os.path.dirname(__file__), 'model.tflite'))
129
  interface = gr.Interface(
130
  fn=inference,
131
  inputs="image",
 
69
 
70
 
71
  class TFliteDemo:
72
+ def __init__(self, model_path, blank=0, conf_mode="min"):
73
  self.blank = blank
74
  self.conf_mode = conf_mode
75
  self.interpreter = tf.lite.Interpreter(model_path=model_path)
 
91
  raise ValueError('img is None')
92
  image = img.copy()
93
  image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
94
+ image = center_fit(image, 192, 96, top_left=True)
95
+ image = np.reshape(image, (1, *image.shape, 1)).astype(np.float32) / 255.0
96
  return image
97
 
98
  def get_confidence(self, pred, mode="mean"):
99
  _argmax = np.argmax(pred, axis=-1)
100
  _idx = _argmax != pred.shape[-1] - 1
101
+ conf = pred[_idx, _argmax[_idx]]
102
+ conf = np.exp(conf)
103
  return np.min(conf) if mode == "min" else np.mean(conf)
104
 
105
  def postprocess(self, pred):
 
126
  </div>
127
  '''
128
  # init model
129
+ demo = TFliteDemo(os.path.join(os.path.dirname(__file__), 'f32_ctr_later_s2.tflite'))
130
  interface = gr.Interface(
131
  fn=inference,
132
  inputs="image",
model.tflite → f32_ctr_later_s2.tflite RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:36adbb170eb545434a5b9216c05f20c311a8357955208b75216928e1bfc38c24
3
- size 82744
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:881ba76cb7ae1c74736f61daea24c61f98b6ef23e147e4eefab32e00e5340d08
3
+ size 89392
label.names CHANGED
@@ -1,4 +1,4 @@
1
- 0
2
  1
3
  2
4
  3
@@ -8,6 +8,7 @@
8
  7
9
  8
10
  9
 
11
 
12
 
13
 
@@ -64,5 +65,4 @@
64
  전남
65
  경북
66
  경남
67
- 제주
68
-
 
1
+
2
  1
3
  2
4
  3
 
8
  7
9
  8
10
  9
11
+ 0
12
 
13
 
14
 
 
65
  전남
66
  경북
67
  경남
68
+ 제주