Commit
•
9aed6e9
1
Parent(s):
3e7d6a0
Add application file
Browse files- Dockerfile +12 -0
- RFNet.onnx +3 -0
- app.py +68 -0
- images/depth_1.png +0 -0
- images/depth_2.png +0 -0
- images/depth_3.png +0 -0
- images/depth_4.png +0 -0
- images/depth_5.png +0 -0
- images/gt_1.png +0 -0
- images/gt_2.png +0 -0
- images/gt_3.png +0 -0
- images/gt_4.png +0 -0
- images/gt_5.png +0 -0
- images/image_1.jpg +0 -0
- images/image_2.jpg +0 -0
- images/image_3.jpg +0 -0
- images/image_4.jpg +0 -0
- images/image_5.jpg +0 -0
- requirements.txt +5 -0
Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ubuntu:20.04
|
2 |
+
|
3 |
+
RUN apt-get update && apt-get install -y \
|
4 |
+
python3 \
|
5 |
+
python3-pip && pip3 install --upgrade pip
|
6 |
+
RUN mkdir /app
|
7 |
+
COPY . /app
|
8 |
+
WORKDIR /app
|
9 |
+
|
10 |
+
RUN pip3 install -r requirements.txt
|
11 |
+
|
12 |
+
CMD ["python3", "app.py"]
|
RFNet.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2dabbbc813e55ce3d9ceb9d51986358d8324716fdde9893ae8f595de8bc8c68b
|
3 |
+
size 365671553
|
app.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import onnxruntime
|
2 |
+
from torchvision import transforms
|
3 |
+
import torch
|
4 |
+
import torch.nn.functional as F
|
5 |
+
import gradio as gr
|
6 |
+
ort_sess = onnxruntime.InferenceSession("RFNet.onnx")
|
7 |
+
|
8 |
+
|
9 |
+
preprocess_img = transforms.Compose([
|
10 |
+
transforms.Resize((352,352)),
|
11 |
+
transforms.ToTensor(),
|
12 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])])
|
13 |
+
|
14 |
+
preprocess_depth = transforms.Compose([
|
15 |
+
transforms.Resize((352,352)),
|
16 |
+
transforms.ToTensor()])
|
17 |
+
def inference(img,depth,GT):
|
18 |
+
h,w = img.size
|
19 |
+
img = preprocess_img(img).unsqueeze(0)
|
20 |
+
depth = preprocess_depth(depth.convert('L')).unsqueeze(0)
|
21 |
+
ort_inputs = {ort_sess.get_inputs()[0].name: img.numpy(), ort_sess.get_inputs()[1].name: depth.numpy()}
|
22 |
+
ort_outs = ort_sess.run(None, ort_inputs)
|
23 |
+
output_image = torch.tensor(ort_outs[0])
|
24 |
+
res = F.interpolate(output_image, size=(w,h), mode='bilinear', align_corners=False)
|
25 |
+
res = torch.sigmoid(res)
|
26 |
+
res = res.data.cpu().numpy().squeeze()
|
27 |
+
res = (res - res.min()) / (res.max() - res.min() + 1e-8)
|
28 |
+
return res
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
title = "Robust RGB-D Fusion for Saliency Detection"
|
36 |
+
description = """ Deployment of the paper:
|
37 |
+
[Robust RGB-D Fusion for Saliency Detection](https://arxiv.org/pdf/2208.01762.pdf)
|
38 |
+
published at the International Conference on 3D Vision 2022 (3DV 2022).
|
39 |
+
Paper Code can be found at [Zongwei97/RFNet](https://github.com/Zongwei97/RFnet).
|
40 |
+
Deployed Code can be found at [shriarul5273/Robust_RGB-D_Saliency_Detection](https://github.com/shriarul5273/Robust_RGB-D_Saliency_Detection).
|
41 |
+
Use example Image and corresponding Depth Map (from NJU2K dataset) or upload your own Image and Depth Map.
|
42 |
+
"""
|
43 |
+
article = """ # Citation
|
44 |
+
If you find this repo useful, please consider citing:
|
45 |
+
```
|
46 |
+
@article{wu2022robust,
|
47 |
+
title={Robust RGB-D Fusion for Saliency Detection},
|
48 |
+
author={Wu, Zongwei and Gobichettipalayam, Shriarulmozhivarman and Tamadazte, Brahim and Allibert, Guillaume and Paudel, Danda Pani and Demonceaux, Cedric},
|
49 |
+
journal={3DV},
|
50 |
+
year={2022}
|
51 |
+
}
|
52 |
+
```
|
53 |
+
"""
|
54 |
+
examples = [['images/image_1.jpg','images/depth_1.png','images/gt_1.png'],
|
55 |
+
['images/image_2.jpg','images/depth_2.png','images/gt_2.png'],
|
56 |
+
['images/image_3.jpg','images/depth_3.png','images/gt_3.png'],
|
57 |
+
['images/image_4.jpg','images/depth_4.png','images/gt_4.png'],
|
58 |
+
['images/image_5.jpg','images/depth_5.png','images/gt_5.png']]
|
59 |
+
|
60 |
+
input_1 = gr.Image(type='pil', label="RGB Image", source="upload")
|
61 |
+
input_2 = gr.Image(type='pil', label="Depth Image", source="upload")
|
62 |
+
input_3 = gr.Image(type='pil', label="Ground Truth", source="upload")
|
63 |
+
outputs = gr.Image(type="pil", label="Saliency Map")
|
64 |
+
|
65 |
+
|
66 |
+
gr.Interface(inference, inputs=[input_1,input_2,input_3], outputs=outputs,
|
67 |
+
title=title,examples=examples,
|
68 |
+
description=description,article=article).launch()
|
images/depth_1.png
ADDED
![]() |
images/depth_2.png
ADDED
![]() |
images/depth_3.png
ADDED
![]() |
images/depth_4.png
ADDED
![]() |
images/depth_5.png
ADDED
![]() |
images/gt_1.png
ADDED
![]() |
images/gt_2.png
ADDED
![]() |
images/gt_3.png
ADDED
![]() |
images/gt_4.png
ADDED
![]() |
images/gt_5.png
ADDED
![]() |
images/image_1.jpg
ADDED
![]() |
images/image_2.jpg
ADDED
![]() |
images/image_3.jpg
ADDED
![]() |
images/image_4.jpg
ADDED
![]() |
images/image_5.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch==1.12.0
|
2 |
+
torchvision==0.13.0
|
3 |
+
Pillow==9.2.0
|
4 |
+
gradio==3.2.0
|
5 |
+
onnxruntime==1.12.1
|