mbar0075 commited on
Commit
1a1fa99
β€’
1 Parent(s): 2e394ee

Arranged Markdown

Browse files
Files changed (1) hide show
  1. app.py +47 -19
app.py CHANGED
@@ -11,7 +11,25 @@ ALPHA = 0.3
11
  GENERATORS = ['itti', 'deepgaze']
12
 
13
  MARKDOWN = """
14
- <h1 style='text-align: center'>Saliency Ranking: Itti vs. Deepgaze</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  """
16
 
17
  IMAGE_EXAMPLES = [
@@ -23,7 +41,8 @@ IMAGE_EXAMPLES = [
23
  def detect_and_annotate(image,
24
  GRID_SIZE,
25
  generator,
26
- ALPHA=ALPHA)-> np.ndarray:
 
27
  # Converting from PIL to OpenCV
28
  image = np.array(image)
29
  # Convert image from BGR to RGB
@@ -37,7 +56,7 @@ def detect_and_annotate(image,
37
  sara.reset()
38
 
39
  # Running sara (Original implementation on itti)
40
- sara_info = sara.return_sara(sara_image, GRID_SIZE, generator, mode=1)
41
 
42
  # Generate saliency map
43
  saliency_map = sara.return_saliency(image, generator=generator)
@@ -67,14 +86,17 @@ def process_image(
67
 
68
  itti_saliency_map, itti_heatmap = detect_and_annotate(
69
  input_image, GRIDSIZE, 'itti')
70
- deepgaze_saliency_map, deepgaze_heatmap = detect_and_annotate(
71
- input_image, GRIDSIZE, 'deepgaze')
 
 
72
 
73
  return (
74
  itti_saliency_map,
75
  itti_heatmap,
76
- deepgaze_saliency_map,
77
- deepgaze_heatmap,
 
78
  )
79
 
80
  grid_size_Component = gr.Slider(
@@ -101,24 +123,28 @@ with gr.Blocks() as demo:
101
  type='pil',
102
  label='Input'
103
  )
104
- with gr.Row():
105
  itti_saliency_map = gr.Image(
106
  type='pil',
107
  label='Itti Saliency Map'
108
  )
 
109
  itti_heatmap = gr.Image(
110
  type='pil',
111
  label='Itti Saliency Ranking Heatmap'
112
  )
113
- with gr.Row():
114
- deepgaze_saliency_map = gr.Image(
115
  type='pil',
116
- label='DeepGaze Saliency Map'
117
- )
118
- deepgaze_heatmap = gr.Image(
119
- type='pil',
120
- label='DeepGaze Saliency Ranking Heatmap'
121
  )
 
 
 
 
 
 
 
 
 
122
  submit_button_component = gr.Button(
123
  value='Submit',
124
  scale=1,
@@ -134,8 +160,9 @@ with gr.Blocks() as demo:
134
  outputs=[
135
  itti_saliency_map,
136
  itti_heatmap,
137
- deepgaze_saliency_map,
138
- deepgaze_heatmap,
 
139
  ]
140
  )
141
 
@@ -148,8 +175,9 @@ with gr.Blocks() as demo:
148
  outputs=[
149
  itti_saliency_map,
150
  itti_heatmap,
151
- deepgaze_saliency_map,
152
- deepgaze_heatmap,
 
153
  ]
154
  )
155
 
 
11
  GENERATORS = ['itti', 'deepgaze']
12
 
13
  MARKDOWN = """
14
+ <h1 style='text-align: center'>Saliency Ranking πŸ₯‡</h1>
15
+
16
+ Saliency Ranking is a fundamental 🌟 **Computer Vision** 🌟 process aimed at discerning the most visually significant features within an image πŸ–ΌοΈ.
17
+
18
+ 🌟 This demo showcases the **SaRa (Saliency-Driven Object Ranking)** model for Saliency Ranking 🎯, which can efficiently rank the visual saliency of an image without requiring any training. πŸ–ΌοΈ
19
+
20
+ This technique is based on the Saliency Map generator model from Itti, which works on the primate visual cortex 🧠, and can work with or without depth information πŸ”„.
21
+
22
+ <div style="display: flex; align-items: center;">
23
+ <a href="https://github.com/dylanseychell/SaliencyRanking" style="margin-right: 10px;">
24
+ <img src="https://badges.aleen42.com/src/github.svg">
25
+ </a>
26
+ <a href="https://github.com/mbar0075/SaRa" style="margin-right: 10px;">
27
+ <img src="https://badges.aleen42.com/src/github.svg">
28
+ </a>
29
+ <a href="https://github.com/matthewkenely/ICT3909" style="margin-right: 10px;">
30
+ <img src="https://badges.aleen42.com/src/github.svg">
31
+ </a>
32
+ </div>
33
  """
34
 
35
  IMAGE_EXAMPLES = [
 
41
  def detect_and_annotate(image,
42
  GRID_SIZE,
43
  generator,
44
+ ALPHA=ALPHA,
45
+ mode=1)-> np.ndarray:
46
  # Converting from PIL to OpenCV
47
  image = np.array(image)
48
  # Convert image from BGR to RGB
 
56
  sara.reset()
57
 
58
  # Running sara (Original implementation on itti)
59
+ sara_info = sara.return_sara(sara_image, GRID_SIZE, generator, mode=mode)
60
 
61
  # Generate saliency map
62
  saliency_map = sara.return_saliency(image, generator=generator)
 
86
 
87
  itti_saliency_map, itti_heatmap = detect_and_annotate(
88
  input_image, GRIDSIZE, 'itti')
89
+ _, itti_heatmap2 = detect_and_annotate(
90
+ input_image, GRIDSIZE, 'itti', mode=2)
91
+ # deepgaze_saliency_map, deepgaze_heatmap = detect_and_annotate(
92
+ # input_image, GRIDSIZE, 'deepgaze')
93
 
94
  return (
95
  itti_saliency_map,
96
  itti_heatmap,
97
+ itti_heatmap2,
98
+ # deepgaze_saliency_map,
99
+ # deepgaze_heatmap,
100
  )
101
 
102
  grid_size_Component = gr.Slider(
 
123
  type='pil',
124
  label='Input'
125
  )
 
126
  itti_saliency_map = gr.Image(
127
  type='pil',
128
  label='Itti Saliency Map'
129
  )
130
+ with gr.Row():
131
  itti_heatmap = gr.Image(
132
  type='pil',
133
  label='Itti Saliency Ranking Heatmap'
134
  )
135
+ itti_heatmap2 = gr.Image(
 
136
  type='pil',
137
+ label='Itti Saliency Ranking Heatmap'
 
 
 
 
138
  )
139
+ # with gr.Row():
140
+ # deepgaze_saliency_map = gr.Image(
141
+ # type='pil',
142
+ # label='DeepGaze Saliency Map'
143
+ # )
144
+ # deepgaze_heatmap = gr.Image(
145
+ # type='pil',
146
+ # label='DeepGaze Saliency Ranking Heatmap'
147
+ # )
148
  submit_button_component = gr.Button(
149
  value='Submit',
150
  scale=1,
 
160
  outputs=[
161
  itti_saliency_map,
162
  itti_heatmap,
163
+ itti_heatmap2,
164
+ # deepgaze_saliency_map,
165
+ # deepgaze_heatmap,
166
  ]
167
  )
168
 
 
175
  outputs=[
176
  itti_saliency_map,
177
  itti_heatmap,
178
+ itti_heatmap2,
179
+ # deepgaze_saliency_map,
180
+ # deepgaze_heatmap,
181
  ]
182
  )
183