saritha5 commited on
Commit
3d722cb
·
1 Parent(s): 586a795

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -101,26 +101,22 @@ def prediction(path_image):
101
  ax[1].imshow(image_np,aspect='auto');
102
 
103
 
104
- return objects
105
- images = ["img1.jpg","img2.jpg","img3.jpg","img4.jpg"]
106
- with st.sidebar:
107
- st.write("choose an image")
108
- st.image(images)
109
- file = st.file_uploader('Upload an Image',type=(["jpeg","jpg","png"]))
110
-
111
- if file is None:
112
- st.write("Please upload an image file")
113
- else:
114
- image= Image.open(file)
115
- st.image(image,use_column_width = True)
116
 
117
- image_path = file
118
  model_path = "//inference"
119
  model_PATH_TO_CKPT = "frozen_inference_graph.pb"
120
  path_to_labels = "tf_label_map.pbtxt"
121
 
122
  result = main(image_path,model_path,model_PATH_TO_CKPT,path_to_labels)
123
- st.write(result)
124
  # print("result-",result)
125
  # list_to_be_sorted= [{'class': 'Y', 'score': 99.97, 'box': (157, 191, 269, 288)}, {'class': '6', 'score': 99.93, 'box': (158, 191, 247, 267)}, {'class': '9', 'score': 99.88, 'box': (156, 190, 179, 196)}, {'class': '4', 'score': 99.8, 'box': (156, 189, 198, 219)}, {'class': '1', 'score': 99.65, 'box': (157, 189, 222, 244)}, {'class': 'F', 'score': 63.4, 'box': (155, 185, 157, 175)}]
126
  newlist = sorted(result, key=lambda k: k['box'][3],reverse=False)
@@ -140,4 +136,17 @@ def prediction(path_image):
140
  print("total time : ",round((total_time_end-total_time_start),2))
141
  st.write(str(simplejson.dumps(response)))
142
 
143
- prediction("img1")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  ax[1].imshow(image_np,aspect='auto');
102
 
103
 
104
+ return fig
105
+ inputs = gr.inputs.Image(type = 'filepath')
106
+ EXAMPLES = ["img1.jpg","img2.jpg","img3.jpg","img4.jpg"]
107
+ DESCRIPTION = """An image is occluded if the image is blocked by any object.
108
+ For example if an electric pole is filled with bushes,the image is occluded since it is not clear and blocked.
109
+ Mobil-net is used to train a model with occluded and non occluded images, so that it can correctly classify the images.
110
+ Occlusion detection can be used to filter unclear images and take safety measures."""
111
+
 
 
 
 
112
 
113
+ image_path = inputs
114
  model_path = "//inference"
115
  model_PATH_TO_CKPT = "frozen_inference_graph.pb"
116
  path_to_labels = "tf_label_map.pbtxt"
117
 
118
  result = main(image_path,model_path,model_PATH_TO_CKPT,path_to_labels)
119
+
120
  # print("result-",result)
121
  # list_to_be_sorted= [{'class': 'Y', 'score': 99.97, 'box': (157, 191, 269, 288)}, {'class': '6', 'score': 99.93, 'box': (158, 191, 247, 267)}, {'class': '9', 'score': 99.88, 'box': (156, 190, 179, 196)}, {'class': '4', 'score': 99.8, 'box': (156, 189, 198, 219)}, {'class': '1', 'score': 99.65, 'box': (157, 189, 222, 244)}, {'class': 'F', 'score': 63.4, 'box': (155, 185, 157, 175)}]
122
  newlist = sorted(result, key=lambda k: k['box'][3],reverse=False)
 
136
  print("total time : ",round((total_time_end-total_time_start),2))
137
  st.write(str(simplejson.dumps(response)))
138
 
139
+
140
+
141
+ demo_app = gr.Interface(
142
+ fn=occ_prediction,
143
+ inputs=inputs,
144
+ outputs= "image",
145
+ title = "Tag Diciphering",
146
+ description = DESCRIPTION,
147
+ examples = EXAMPLES,
148
+ #cache_example = True,
149
+ #live = True,
150
+ theme = 'huggingface'
151
+ )
152
+ demo_app.launch()