amaurisarchibald commited on
Commit
0864015
·
verified ·
1 Parent(s): fee13cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -97,7 +97,11 @@ def inferenceScore(image_url, image, min_score, model_name):
97
  v = Visualizer(im, models[model_id]["metadata"], scale=1.2)
98
  out = v.draw_instance_predictions(outputs["instances"].scores[1])
99
 
100
- return out
 
 
 
 
101
 
102
  title = "# DBMDZ Detectron2 Model Demo"
103
  description = """
@@ -126,9 +130,13 @@ with gr.Blocks() as demo:
126
 
127
  output_image = gr.Image(type="pil", label="Output")
128
 
 
129
  inference_button = gr.Button("Submit")
130
 
131
- inference_button.click(fn=inferenceScore, inputs=[url_input, image_input, min_score, model_name], outputs=output_image)
 
 
 
132
 
133
  gr.Markdown(footer)
134
 
 
97
  v = Visualizer(im, models[model_id]["metadata"], scale=1.2)
98
  out = v.draw_instance_predictions(outputs["instances"].scores[1])
99
 
100
+ damage_class_map= {0:'damage'}
101
+ damage_prediction_classes = [ damage_class_map[el] + "_" + str(indx) for indx,el in enumerate(outputs["instances"].pred_classes.tolist())]
102
+ damage_polygon_centers = outputs["instances"].pred_boxes.get_centers().tolist()
103
+ damage_dict = dict(zip(damage_prediction_classes,damage_polygon_centers))
104
+ return damage_dict
105
 
106
  title = "# DBMDZ Detectron2 Model Demo"
107
  description = """
 
130
 
131
  output_image = gr.Image(type="pil", label="Output")
132
 
133
+ label = gr.outputs.Label()
134
  inference_button = gr.Button("Submit")
135
 
136
+ #inference_button.click(fn=inferenceScore, inputs=[url_input, image_input, min_score, model_name], outputs=output_image)
137
+
138
+ inference_button.click(fn=inferenceScore, inputs=[url_input, image_input, min_score, model_name], outputs=label)
139
+
140
 
141
  gr.Markdown(footer)
142