sezer91 commited on
Commit
ea3ca30
·
1 Parent(s): fa3b6b9

Add application file

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -1,7 +1,20 @@
1
- import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ from PIL import Image
3
+ import numpy as np
4
 
5
+ def show_mask(mask, ax, random_color=False):
6
+ if random_color:
7
+ color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0)
8
+ else:
9
+ color = np.array([30 / 255, 144 / 255, 255 / 255, 0.6])
10
+ h, w = mask.shape[-2:]
11
+ mask_image = mask.reshape(h, w, 1) * color.reshape(1, 1, -1)
12
+ ax.imshow(mask_image)
13
+
14
 
15
+ plt.imshow(np.array(raw_image))
16
+ ax = plt.gca()
17
+ for mask in outputs["masks"]:
18
+ show_mask(mask, ax=ax, random_color=True)
19
+ plt.axis("off")
20
+ plt.show()