Spaces:
Running
on
Zero
Running
on
Zero
ZhengPeng7
commited on
Commit
·
a6ceb33
1
Parent(s):
398e876
Set 4 images as input.
Browse files- app.py +10 -11
- example_images/butterfly/22398.jpg +0 -0
- example_images/butterfly/22987.jpg +0 -0
- example_images/butterfly/22998.jpg +0 -0
- example_images/butterfly/354528.jpg +0 -0
- example_images/butterfly/3751159.jpg +0 -0
- example_images/butterfly/4013494.jpg +0 -0
- example_images/butterfly/4277400.jpg +0 -0
- example_images/butterfly/4320159.jpg +0 -0
- example_images/butterfly/4362807.jpg +0 -0
- example_images/butterfly/4375789.jpg +0 -0
- example_images/butterfly/4392735.jpg +0 -0
- example_images/butterfly/4672380.jpg +0 -0
app.py
CHANGED
@@ -34,8 +34,8 @@ if os.path.exists(state_dict):
|
|
34 |
model.eval()
|
35 |
|
36 |
|
37 |
-
def pred_maps(
|
38 |
-
images = [
|
39 |
image_shapes = [image.shape[:2] for image in images]
|
40 |
images = [Image.fromarray(image) for image in images]
|
41 |
|
@@ -55,19 +55,18 @@ def pred_maps(dr):
|
|
55 |
image_preds = []
|
56 |
for image, pred in zip(images, preds):
|
57 |
image_preds.append(
|
58 |
-
cv2.cvtColor(
|
59 |
np.hstack([np.array(image.convert('RGB')), cv2.cvtColor((pred*255).astype(np.uint8), cv2.COLOR_GRAY2RGB)]),
|
60 |
-
cv2.COLOR_BGR2RGB
|
61 |
-
)
|
62 |
-
# for image_pred in image_preds:
|
63 |
-
# cv2.imwrite('a.png', cv2.cvtColor(image_pred, cv2.COLOR_RGB2BGR))
|
64 |
return image_preds[:]
|
65 |
|
66 |
|
67 |
-
|
|
|
68 |
|
69 |
-
ipt = [
|
70 |
-
opt =
|
71 |
demo = gr.Interface(
|
72 |
fn=pred_maps,
|
73 |
inputs=ipt,
|
@@ -75,6 +74,6 @@ demo = gr.Interface(
|
|
75 |
examples=examples,
|
76 |
interpretation='default',
|
77 |
title='Online demo for `GCoNet+: A Stronger Group Collaborative Co-Salient Object Detector (T-PAMI 2023)`',
|
78 |
-
description='Upload pictures, most of which contain salient objects of the same class
|
79 |
)
|
80 |
demo.launch(debug=True)
|
|
|
34 |
model.eval()
|
35 |
|
36 |
|
37 |
+
def pred_maps(image_1, image_2, image_3, image_4):
|
38 |
+
images = [image_1, image_2, image_3, image_4]
|
39 |
image_shapes = [image.shape[:2] for image in images]
|
40 |
images = [Image.fromarray(image) for image in images]
|
41 |
|
|
|
55 |
image_preds = []
|
56 |
for image, pred in zip(images, preds):
|
57 |
image_preds.append(
|
58 |
+
# cv2.cvtColor(
|
59 |
np.hstack([np.array(image.convert('RGB')), cv2.cvtColor((pred*255).astype(np.uint8), cv2.COLOR_GRAY2RGB)]),
|
60 |
+
# cv2.COLOR_BGR2RGB)
|
61 |
+
)
|
|
|
|
|
62 |
return image_preds[:]
|
63 |
|
64 |
|
65 |
+
N = 4
|
66 |
+
examples = [[_] for _ in glob('example_images/butterfly/*')][:N]
|
67 |
|
68 |
+
ipt = [gr.Image().style(width=600, height=150) for _ in range(N)]
|
69 |
+
opt = [gr.Image().style(width=600, height=150) for _ in range(N)]
|
70 |
demo = gr.Interface(
|
71 |
fn=pred_maps,
|
72 |
inputs=ipt,
|
|
|
74 |
examples=examples,
|
75 |
interpretation='default',
|
76 |
title='Online demo for `GCoNet+: A Stronger Group Collaborative Co-Salient Object Detector (T-PAMI 2023)`',
|
77 |
+
description='Upload pictures, most of which contain salient objects of the same class. Our demo will give you the binary maps of these co-salient objects :)\n**********Example images need to be dropped into each block, instead of click.**********'
|
78 |
)
|
79 |
demo.launch(debug=True)
|
example_images/butterfly/22398.jpg
DELETED
Binary file (47.9 kB)
|
|
example_images/butterfly/22987.jpg
DELETED
Binary file (45 kB)
|
|
example_images/butterfly/22998.jpg
DELETED
Binary file (53.8 kB)
|
|
example_images/butterfly/354528.jpg
DELETED
Binary file (49.4 kB)
|
|
example_images/butterfly/3751159.jpg
DELETED
Binary file (34.9 kB)
|
|
example_images/butterfly/4013494.jpg
DELETED
Binary file (79.9 kB)
|
|
example_images/butterfly/4277400.jpg
DELETED
Binary file (51 kB)
|
|
example_images/butterfly/4320159.jpg
DELETED
Binary file (55.8 kB)
|
|
example_images/butterfly/4362807.jpg
DELETED
Binary file (29.6 kB)
|
|
example_images/butterfly/4375789.jpg
DELETED
Binary file (42 kB)
|
|
example_images/butterfly/4392735.jpg
DELETED
Binary file (47.5 kB)
|
|
example_images/butterfly/4672380.jpg
DELETED
Binary file (75.3 kB)
|
|