Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,10 +115,10 @@ def main_func(inputs):
|
|
| 115 |
final_mask = masks[0]
|
| 116 |
mask_colors = np.zeros((final_mask.shape[0], final_mask.shape[1], 3), dtype=np.uint8)
|
| 117 |
mask_colors[final_mask, :] = np.array([[256, 0, 0]])
|
| 118 |
-
return Image.fromarray((mask_colors+ image_input).astype('uint8'), 'RGB')
|
| 119 |
else:
|
| 120 |
print('Prediction:: No vehicle found in the image')
|
| 121 |
-
return Image.fromarray(image_input)
|
| 122 |
|
| 123 |
def reset_data():
|
| 124 |
global cache_data
|
|
@@ -128,12 +128,15 @@ with gr.Blocks() as demo:
|
|
| 128 |
gr.Markdown("# Vehicle damage detection")
|
| 129 |
gr.Markdown("""This app uses the SAM model and clipseg model to get a vehicle damage area from image.""")
|
| 130 |
with gr.Row():
|
| 131 |
-
image_input = gr.Image()
|
| 132 |
-
image_output = gr.Image()
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
image_button = gr.Button("Segment Image", variant='primary')
|
| 135 |
|
| 136 |
-
image_button.click(main_func, inputs=image_input, outputs=image_output)
|
| 137 |
image_input.upload(reset_data)
|
| 138 |
|
| 139 |
demo.launch()
|
|
|
|
| 115 |
final_mask = masks[0]
|
| 116 |
mask_colors = np.zeros((final_mask.shape[0], final_mask.shape[1], 3), dtype=np.uint8)
|
| 117 |
mask_colors[final_mask, :] = np.array([[256, 0, 0]])
|
| 118 |
+
return 'Prediction: Vehicle damage prediction is given.',Image.fromarray((mask_colors+ image_input).astype('uint8'), 'RGB')
|
| 119 |
else:
|
| 120 |
print('Prediction:: No vehicle found in the image')
|
| 121 |
+
return 'Prediction:: No vehicle or damage found in the image',Image.fromarray(image_input)
|
| 122 |
|
| 123 |
def reset_data():
|
| 124 |
global cache_data
|
|
|
|
| 128 |
gr.Markdown("# Vehicle damage detection")
|
| 129 |
gr.Markdown("""This app uses the SAM model and clipseg model to get a vehicle damage area from image.""")
|
| 130 |
with gr.Row():
|
| 131 |
+
image_input = gr.Image(label='Input Image')
|
| 132 |
+
image_output = gr.Image(label='Damage Detection')
|
| 133 |
+
with gr.Row():
|
| 134 |
+
examples = gr.Examples(examples="./examples", inputs=image_input)
|
| 135 |
+
prediction_op = gr.gradio.Textbox(label='Prediction')
|
| 136 |
|
| 137 |
image_button = gr.Button("Segment Image", variant='primary')
|
| 138 |
|
| 139 |
+
image_button.click(main_func, inputs=image_input, outputs=[prediction_op, image_output])
|
| 140 |
image_input.upload(reset_data)
|
| 141 |
|
| 142 |
demo.launch()
|