amosfang commited on
Commit
8f78a6d
1 Parent(s): f2df218

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import matplotlib.pyplot as plt
2
  import numpy as np
3
- from six import BytesIO
4
  from PIL import Image
5
  import tensorflow as tf
6
  from object_detection.utils import label_map_util
@@ -10,7 +9,8 @@ import tarfile
10
  import wget
11
  import gradio as gr
12
  from huggingface_hub import snapshot_download
13
- import os
 
14
 
15
  PATH_TO_LABELS = 'data/label_map.pbtxt'
16
  category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
@@ -20,13 +20,7 @@ def pil_image_as_numpy_array(pilimg):
20
  img_array = tf.keras.utils.img_to_array(pilimg)
21
  # img_array = np.expand_dims(img_array, axis=0)
22
  return img_array
23
-
24
- def load_image_into_numpy_array(path):
25
-
26
- image = None
27
- image_data = tf.io.gfile.GFile(path, 'rb').read()
28
- image = Image.open(BytesIO(image_data))
29
- return pil_image_as_numpy_array(image)
30
 
31
  def load_model():
32
  model_dir = 'saved_model'
 
1
  import matplotlib.pyplot as plt
2
  import numpy as np
 
3
  from PIL import Image
4
  import tensorflow as tf
5
  from object_detection.utils import label_map_util
 
9
  import wget
10
  import gradio as gr
11
  from huggingface_hub import snapshot_download
12
+ import os
13
+ import cv2
14
 
15
  PATH_TO_LABELS = 'data/label_map.pbtxt'
16
  category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
 
20
  img_array = tf.keras.utils.img_to_array(pilimg)
21
  # img_array = np.expand_dims(img_array, axis=0)
22
  return img_array
23
+
 
 
 
 
 
 
24
 
25
  def load_model():
26
  model_dir = 'saved_model'