Tidy Up the mess...
Browse files
app.py
CHANGED
@@ -89,16 +89,18 @@ def predict(img):
|
|
89 |
fig.add_axes(ax)
|
90 |
ax.imshow(den_map, aspect='auto')
|
91 |
|
92 |
-
return pred_cnt, fig
|
93 |
|
94 |
|
95 |
with gr.Blocks() as demo:
|
96 |
gr.Markdown("""
|
97 |
# Crowd Counting based on SASNet
|
98 |
-
|
99 |
We implemented a image crowd counting model with VGG16 following the paper of Song et. al (2021).
|
|
|
100 |
|
101 |
-
## Abstract
|
|
|
102 |
In this paper, we address the large scale variation problem in crowd counting by taking full advantage of the multi-scale feature representations in a multi-level network. We
|
103 |
implement such an idea by keeping the counting error of a patch as small as possible with a proper feature level selection strategy, since a specific feature level tends to perform
|
104 |
better for a certain range of scales. However, without scale annotations, it is sub-optimal and error-prone to manually assign the predictions for heads of different scales to
|
@@ -108,26 +110,38 @@ with gr.Blocks() as demo:
|
|
108 |
scale, we conduct the adaptive selection strategy in a patch-wise style. However, pixels within a patch contribute different counting errors due to the various difficulty degrees of
|
109 |
learning. Thus, we further propose a Pyramid Region Awareness Loss (PRA Loss) to recursively select the most hard sub-regions within a patch until reaching the pixel level. With
|
110 |
awareness of whether the parent patch is over-estimated or under-estimated, the fine-grained optimization with the PRA Loss for these region-aware hard pixels helps to alleviate the
|
111 |
-
inconsistency problem between training target and evaluation metric. The state-of-the-art results on four datasets demonstrate the superiority of our approach.
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
## References
|
116 |
-
Song, Q., Wang, C., Wang, Y., Tai, Y., Wang, C., Li, J., … Ma, J. (2021). To Choose or to Fuse? Scale Selection for Crowd Counting.
|
117 |
-
The Thirty-Fifth AAAI Conference on Artificial Intelligence (AAAI-21).
|
118 |
""")
|
|
|
|
|
|
|
|
|
|
|
119 |
with gr.Row():
|
120 |
with gr.Column():
|
121 |
image_input = gr.Image(type="pil")
|
122 |
-
gr.Examples(["IMG_1.jpg", "IMG_2.jpg", "IMG_3.jpg"], image_input)
|
123 |
with gr.Column():
|
124 |
image_output = gr.Plot()
|
|
|
125 |
with gr.Column():
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
image_button.click(predict, inputs=image_input, outputs=[text_output, image_output])
|
131 |
|
132 |
-
demo.launch(debug = True)
|
133 |
|
|
|
89 |
fig.add_axes(ax)
|
90 |
ax.imshow(den_map, aspect='auto')
|
91 |
|
92 |
+
return int(np.round(pred_cnt, 0)), fig
|
93 |
|
94 |
|
95 |
with gr.Blocks() as demo:
|
96 |
gr.Markdown("""
|
97 |
# Crowd Counting based on SASNet
|
98 |
+
<p>
|
99 |
We implemented a image crowd counting model with VGG16 following the paper of Song et. al (2021).
|
100 |
+
</p>
|
101 |
|
102 |
+
## Abstract
|
103 |
+
<p>
|
104 |
In this paper, we address the large scale variation problem in crowd counting by taking full advantage of the multi-scale feature representations in a multi-level network. We
|
105 |
implement such an idea by keeping the counting error of a patch as small as possible with a proper feature level selection strategy, since a specific feature level tends to perform
|
106 |
better for a certain range of scales. However, without scale annotations, it is sub-optimal and error-prone to manually assign the predictions for heads of different scales to
|
|
|
110 |
scale, we conduct the adaptive selection strategy in a patch-wise style. However, pixels within a patch contribute different counting errors due to the various difficulty degrees of
|
111 |
learning. Thus, we further propose a Pyramid Region Awareness Loss (PRA Loss) to recursively select the most hard sub-regions within a patch until reaching the pixel level. With
|
112 |
awareness of whether the parent patch is over-estimated or under-estimated, the fine-grained optimization with the PRA Loss for these region-aware hard pixels helps to alleviate the
|
113 |
+
inconsistency problem between training target and evaluation metric. The state-of-the-art results on four datasets demonstrate the superiority of our approach.
|
114 |
+
</p>
|
115 |
+
|
116 |
+
## Demo
|
|
|
|
|
|
|
117 |
""")
|
118 |
+
with gr.Row():
|
119 |
+
with gr.Column():
|
120 |
+
gr.Markdown("")
|
121 |
+
with gr.Column():
|
122 |
+
text_output = gr.Label()
|
123 |
with gr.Row():
|
124 |
with gr.Column():
|
125 |
image_input = gr.Image(type="pil")
|
|
|
126 |
with gr.Column():
|
127 |
image_output = gr.Plot()
|
128 |
+
with gr.Row():
|
129 |
with gr.Column():
|
130 |
+
image_button = gr.Button("Count the Crowd!", variant = "primary")
|
131 |
+
with gr.Column():
|
132 |
+
gr.Markdown("")
|
133 |
+
with gr.Column():
|
134 |
+
gr.Markdown("")
|
135 |
+
|
136 |
+
gr.Examples(["IMG_1.jpg", "IMG_2.jpg", "IMG_3.jpg"], image_input)
|
137 |
+
|
138 |
+
gr.Markdown("""
|
139 |
+
## References
|
140 |
+
The code will be available at: https://github.com/TencentYoutuResearch/CrowdCounting-SASNet.
|
141 |
+
Song, Q., Wang, C., Wang, Y., Tai, Y., Wang, C., Li, J., … Ma, J. (2021). To Choose or to Fuse? Scale Selection for Crowd Counting. The Thirty-Fifth AAAI Conference on Artificial Intelligence (AAAI-21).
|
142 |
+
""")
|
143 |
|
144 |
image_button.click(predict, inputs=image_input, outputs=[text_output, image_output])
|
145 |
|
146 |
+
demo.launch(debug = True, share=True)
|
147 |
|