Spaces:
Running
Running
Update Webpage.py
Browse files- Webpage.py +42 -31
Webpage.py
CHANGED
@@ -104,40 +104,51 @@ def attention(notes, download1, download2, whole_display_prompt,
|
|
104 |
ad_embeddings=ad_topic, ctpg_embeddings=ctpg_topic,
|
105 |
surface_sizes=surfaces, Product_Group=prod_group,
|
106 |
obj_detection_model_pth=None, num_topic=20, Gaze_Time_Type=gaze_type)
|
107 |
-
return np.round(Gaze,2), Image.fromarray(np.flip(heatmap, axis=2))
|
108 |
|
109 |
def greet(name, intensity):
|
110 |
return "Hello " * intensity + name + "!"
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
demo.launch(share=True)
|
|
|
104 |
ad_embeddings=ad_topic, ctpg_embeddings=ctpg_topic,
|
105 |
surface_sizes=surfaces, Product_Group=prod_group,
|
106 |
obj_detection_model_pth=None, num_topic=20, Gaze_Time_Type=gaze_type)
|
107 |
+
return notes, notes, np.round(Gaze,2), notes, Image.fromarray(np.flip(heatmap, axis=2))
|
108 |
|
109 |
def greet(name, intensity):
|
110 |
return "Hello " * intensity + name + "!"
|
111 |
|
112 |
+
with gr.Blocks() as demo:
|
113 |
+
gr.Interface(
|
114 |
+
fn=attention,
|
115 |
+
inputs=[gr.Markdown("""
|
116 |
+
Instruction:
|
117 |
+
1. Click to upload or drag the entire image that contains BOTH ad and its context;
|
118 |
+
2. Draw bounding boxes in the order of: (each element can have more than 1 boxes; remember the number of boxes for each element you draw)
|
119 |
+
(a) Brand element(s) (skip if N.A.)
|
120 |
+
(b) Pictorial element(s), e.g. Objects, Person etc (skip if N.A.)
|
121 |
+
(c) Text element(s) (skip if N.A.)
|
122 |
+
(d) The advertisement.
|
123 |
+
|
124 |
+
Two example ads are avialable for download: """),
|
125 |
+
gr.DownloadButton(label="Download Example Image 1 of Ad and Context", value='Demo/Ad_Example1.jpg'),
|
126 |
+
gr.DownloadButton(label="Download Example Image 2 of Ad and Context", value='Demo/Ad_Example2.jpg'),
|
127 |
+
ImagePrompter(label="Upload Entire (Ad+Context) Image, and Draw Bounding Boxes", sources=['upload'], type="pil"),
|
128 |
+
gr.Number(label="Number of brand bounding boxes drawn"),
|
129 |
+
gr.Number(label="Number of pictorial bounding boxes drawn"),
|
130 |
+
gr.Number(label="Number of text bounding boxes drawn"),
|
131 |
+
gr.Dropdown(CATEGORIES, label="Product Category"),
|
132 |
+
gr.Dropdown(LOCATIONS, label='Ad Location'),
|
133 |
+
gr.Dropdown(GAZE_TYPE, label='Gaze Type')
|
134 |
+
],
|
135 |
+
outputs=[gr.Markdown("""Note: Outputs could take around 70-80 seconds under current CPU environment (due to ResNet model)."""),
|
136 |
+
gr.Markdown("""### Predicted Gaze (sec) """),
|
137 |
+
gr.Number(show_label=False),
|
138 |
+
gr.Markdown("""### Heatmap by ResNet50 (Hotter/Redder regions show more contribution)"""),
|
139 |
+
gr.Image(show_label=False)],
|
140 |
+
title="Gazer 1.0: Ad Attention Prediction",
|
141 |
+
description="""This app accompanies: "Contextual Advertising with Theory-Informed Machine Learning", manuscript submitted to the Journal of Marketing.
|
142 |
+
App Version: 1.0, Date: 10/24/2024.
|
143 |
+
Note: Gazer 1.0 does not yet include LLM generated ad topics. Future updates will include this in a GPU environment.""",
|
144 |
+
theme=gr.themes.Soft()
|
145 |
+
)
|
146 |
+
gr.Markdown(
|
147 |
+
"""
|
148 |
+
<div style='text-align: center; padding: 10px;'>
|
149 |
+
<p>Copyright © 2024 Manuscript Authors. All Rights Reserved.</p>
|
150 |
+
</div>
|
151 |
+
"""
|
152 |
+
)
|
153 |
|
154 |
demo.launch(share=True)
|