sokonana commited on
Commit
a576b62
1 Parent(s): 730ad99

Use only SSD MobileNet model

Browse files
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -11,7 +11,7 @@ from huggingface_hub import snapshot_download
11
  import os
12
  import gradio as gr
13
 
14
- MODEL_REPO = 'sokonana/it107model' # default model selected
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)
17
 
@@ -36,17 +36,12 @@ def load_model():
36
  return detection_model
37
 
38
 
39
- def predict(pilimg, model):
40
-
41
- if model == 'ResNet':
42
- MODEL_REPO = 'sokonana/it107model2'
43
 
44
  image_np = pil_image_as_numpy_array(pilimg)
45
  return predict2(image_np)
46
 
47
  def predict2(image_np):
48
-
49
- detection_model = load_model()
50
  results = detection_model(image_np)
51
 
52
  # different object detection models have additional results
@@ -71,14 +66,9 @@ def predict2(image_np):
71
 
72
  return result_pil_img
73
 
74
- # detection_model = load_model()
75
- # pil_image = Image.open(image_path)
76
- # image_arr = pil_image_as_numpy_array(pil_image)
77
-
78
- # predicted_img = predict(image_arr)
79
- # predicted_img.save('predicted.jpg')
80
 
81
  gr.Interface(fn=predict,
82
- inputs=[gr.Image(type="pil"), gr.Radio(['MobileNet', 'ResNet'],label='Model Selection', value='MobileNet')],
83
  outputs=gr.Image(type="pil")
84
  ).launch(share=True)
 
11
  import os
12
  import gradio as gr
13
 
14
+ MODEL_REPO = 'sokonana/it107model'
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)
17
 
 
36
  return detection_model
37
 
38
 
39
+ def predict(pilimg):
 
 
 
40
 
41
  image_np = pil_image_as_numpy_array(pilimg)
42
  return predict2(image_np)
43
 
44
  def predict2(image_np):
 
 
45
  results = detection_model(image_np)
46
 
47
  # different object detection models have additional results
 
66
 
67
  return result_pil_img
68
 
69
+ detection_model = load_model()
 
 
 
 
 
70
 
71
  gr.Interface(fn=predict,
72
+ inputs=[gr.Image(type="pil")],
73
  outputs=gr.Image(type="pil")
74
  ).launch(share=True)