add questionnaire
Browse files- .gitignore +2 -0
- app.py +36 -0
- pages/annotation.py +132 -0
- pages/demographics.py +157 -0
- pages/login.py +21 -3
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.idea
|
2 |
+
__pycache__
|
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
|
5 |
+
def load_results():
|
6 |
+
return pd.read_csv("results/results.csv")
|
7 |
+
|
8 |
+
c = pd.DataFrame()
|
9 |
+
c.to_csv("results/results.csv")
|
10 |
+
results = load_results()
|
11 |
+
st.session_state["results"] = results
|
12 |
+
|
13 |
+
|
14 |
+
st.set_page_config(
|
15 |
+
page_title="ciVIS",
|
16 |
+
page_icon="👋"
|
17 |
+
)
|
18 |
+
|
19 |
+
st.title("Studio sulla City Identity")
|
20 |
+
|
21 |
+
st.markdown(
|
22 |
+
"""## Benvenuto/a!
|
23 |
+
|
24 |
+
Prima di tutto, grazie per la tua disponibilità a prendere parte a questo studio!
|
25 |
+
Questo studio è parte della mia tesi di Dottorato in ..., il cui obiettivo è ...
|
26 |
+
Durante l'esperimento, ti chiederemo di selezionare alcuni parametri per la generazione di un'immagine con un algoritmo
|
27 |
+
di intelligence artificiale.
|
28 |
+
Ti sarà quindi chiesto di rispondere ad un breve questionario sull'immagine generata per sapere la tua opinione sul
|
29 |
+
risultato, rispetto a quelle che erano le tue aspettative.
|
30 |
+
L'esperimento richiede circa 6 ore e puoi organizzare l'annotazione come ritieni più comodo.
|
31 |
+
|
32 |
+
Per sapere di più sul Centro interdipartimentale sulla Visualità, [clicca qui](https://ci-vis.unige.it/)
|
33 |
+
"""
|
34 |
+
)
|
35 |
+
|
36 |
+
st.page_link("pages/login.py", label="Inizia")
|
pages/annotation.py
CHANGED
@@ -1,5 +1,137 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
st.title("Studio sulla City Identity")
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pandas as pd
|
3 |
import streamlit as st
|
4 |
+
from datasets import load_dataset
|
5 |
+
from streamlit_tags import st_tags
|
6 |
|
7 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
8 |
+
|
9 |
+
|
10 |
+
def save_data():
|
11 |
+
st.session_state["user"]["part_two"] = {
|
12 |
+
"aesthetic": aesthetic,
|
13 |
+
"real_buildings": real_buildings,
|
14 |
+
"confidence": confidence,
|
15 |
+
"expectation": expectation,
|
16 |
+
"coherent": coherent,
|
17 |
+
"coherent_others": coherent_others,
|
18 |
+
"not_coherent": not_coherent,
|
19 |
+
"not_coherent_others": not_coherent_others,
|
20 |
+
"feedback": feedback
|
21 |
+
}
|
22 |
+
|
23 |
+
results = {
|
24 |
+
"user": st.session_state["user"]["nickname"],
|
25 |
+
**st.session_state["user"]["part_one"],
|
26 |
+
**st.session_state["user"]["part_two"]
|
27 |
+
}
|
28 |
+
df = pd.DataFrame.from_dict(results, orient="index").T
|
29 |
+
df = pd.concat(
|
30 |
+
[st.session_state["results"], df]
|
31 |
+
)
|
32 |
+
df.to_csv("results/results.csv")
|
33 |
+
|
34 |
+
|
35 |
+
@st.cache_resource
|
36 |
+
def get_dataset():
|
37 |
+
return load_dataset(
|
38 |
+
"Nicorb/test_img",
|
39 |
+
split="train",
|
40 |
+
token=HF_TOKEN
|
41 |
+
)
|
42 |
+
|
43 |
+
|
44 |
+
dataset = get_dataset()
|
45 |
|
46 |
st.title("Studio sulla City Identity")
|
47 |
|
48 |
+
with st.form("valutazione_immagine"):
|
49 |
+
st.image(
|
50 |
+
dataset[0]["image"]
|
51 |
+
)
|
52 |
+
|
53 |
+
aesthetic = st.radio(
|
54 |
+
"L'immagine mi piace",
|
55 |
+
[
|
56 |
+
"1 - Per nulla",
|
57 |
+
"2",
|
58 |
+
"3",
|
59 |
+
"4",
|
60 |
+
"5 - Totalmente"
|
61 |
+
],
|
62 |
+
horizontal=True
|
63 |
+
)
|
64 |
+
|
65 |
+
real_buildings = st.radio(
|
66 |
+
"Penso che gli edifici nell'immagine esistano realmente:",
|
67 |
+
[
|
68 |
+
"Si", "No"
|
69 |
+
]
|
70 |
+
)
|
71 |
+
|
72 |
+
confidence = st.radio(
|
73 |
+
"Sono convinto/a della mia risposta",
|
74 |
+
[
|
75 |
+
"1 - Per nulla",
|
76 |
+
"2",
|
77 |
+
"3",
|
78 |
+
"4",
|
79 |
+
"5 - Totalmente"
|
80 |
+
],
|
81 |
+
horizontal=True
|
82 |
+
)
|
83 |
+
|
84 |
+
expectation = st.radio(
|
85 |
+
"Gli edifici nell'immagine rispettano la mia aspettativa sulla città di Genova",
|
86 |
+
[
|
87 |
+
"1 - Per nulla d'accordo",
|
88 |
+
"2",
|
89 |
+
"3",
|
90 |
+
"4",
|
91 |
+
"5 - Pienamente d'accordo"
|
92 |
+
],
|
93 |
+
horizontal=True
|
94 |
+
)
|
95 |
+
|
96 |
+
coherent = st.multiselect(
|
97 |
+
"Penso che le seguenti caratteristiche dell'immagine siano coerenti con le mie aspettative:",
|
98 |
+
[
|
99 |
+
"colore", "nitidezza", "aspetto realistico", "aspetto surreale", "stile architettonico",
|
100 |
+
"difetti dell'immagine", "presenza del contesto", "correttezza del contesto (se presente)",
|
101 |
+
"coerenza con la città", "tratti caratteristici della città" # aggiungere ripetizione? troppi elementi?
|
102 |
+
],
|
103 |
+
placeholder="Seleziona gli elementi"
|
104 |
+
)
|
105 |
+
coherent_others = st_tags(
|
106 |
+
label="Altre caratteristiche:",
|
107 |
+
text="Premere invio per aggiungere un nuovo elemento",
|
108 |
+
value=[],
|
109 |
+
maxtags=-1,
|
110 |
+
key="coherent"
|
111 |
+
)
|
112 |
+
|
113 |
+
not_coherent = st.multiselect(
|
114 |
+
"Penso che le seguenti caratteristiche dell'immagine NON siano coerenti con le mie aspettative:",
|
115 |
+
[
|
116 |
+
"colore", "nitidezza", "aspetto realistico", "aspetto surreale", "stile architettonico",
|
117 |
+
"difetti dell'immagine", "presenza del contesto", "correttezza del contesto (se presente)",
|
118 |
+
"coerenza con la città", "tratti caratteristici della città" # aggiungere ripetizione? troppi elementi?
|
119 |
+
],
|
120 |
+
placeholder="Seleziona gli elementi"
|
121 |
+
)
|
122 |
+
not_coherent_others = st_tags(
|
123 |
+
label="Altre caratteristiche:",
|
124 |
+
text="Premere invio per aggiungere un nuovo elemento",
|
125 |
+
value=[],
|
126 |
+
maxtags=-1,
|
127 |
+
key="not_coherent"
|
128 |
+
)
|
129 |
+
|
130 |
+
feedback = st.text_area("Note, idee, suggerimenti e osservazioni")
|
131 |
+
|
132 |
+
submit = st.form_submit_button("Salva", on_click=save_data)
|
133 |
+
|
134 |
+
if submit:
|
135 |
+
st.success("Salvataggio completato")
|
136 |
+
|
137 |
+
st.page_link("pages/annotation.py", label="Continua")
|
pages/demographics.py
CHANGED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_tags import st_tags
|
3 |
+
|
4 |
+
|
5 |
+
def store_user():
|
6 |
+
st.session_state["users"].append(st.session_state["user"])
|
7 |
+
st.session_state["user"]["part_one"] = {
|
8 |
+
"age": age,
|
9 |
+
"school": school,
|
10 |
+
"work": work,
|
11 |
+
"work_other": work_other,
|
12 |
+
"img_rapport": img_rapport,
|
13 |
+
"img_other": img_other,
|
14 |
+
"img_freq": img_freq,
|
15 |
+
"img_expert": img_expert,
|
16 |
+
"ai_expert": ai_expert,
|
17 |
+
"genova_expert": genova_expert,
|
18 |
+
"genova_freq": genova_freq,
|
19 |
+
"genova_knowledge": genova_knowledge,
|
20 |
+
"genova_thoughts": genova_thoughts
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
st.title("Studio sulla City Identity")
|
25 |
+
|
26 |
+
with st.form("demografica"):
|
27 |
+
age = st.radio(
|
28 |
+
"Età",
|
29 |
+
[
|
30 |
+
"18-24",
|
31 |
+
"25-34",
|
32 |
+
"35-44",
|
33 |
+
"45-54",
|
34 |
+
"55-64",
|
35 |
+
"65-74"
|
36 |
+
]
|
37 |
+
)
|
38 |
+
school = st.radio(
|
39 |
+
"Grado di istruzione",
|
40 |
+
[
|
41 |
+
"Licenza media",
|
42 |
+
"Scuola superiore",
|
43 |
+
"Laurea triennale",
|
44 |
+
"Laurea specialistica",
|
45 |
+
"Dottorato di ricerca"
|
46 |
+
]
|
47 |
+
)
|
48 |
+
work = st.radio(
|
49 |
+
"Mi occupo di",
|
50 |
+
[
|
51 |
+
"Architettura",
|
52 |
+
"Design",
|
53 |
+
"Informatica",
|
54 |
+
"Altro"
|
55 |
+
]
|
56 |
+
)
|
57 |
+
work_other = st.text_input("Se altro, indica cosa...")
|
58 |
+
|
59 |
+
img_rapport = st.radio(
|
60 |
+
"Il mio rapporto con le immagini è:",
|
61 |
+
[
|
62 |
+
"Professionale",
|
63 |
+
"Hobbistico",
|
64 |
+
"Nessuno",
|
65 |
+
"Altro"
|
66 |
+
]
|
67 |
+
)
|
68 |
+
img_other = st.text_input("Se altro, indica quale...")
|
69 |
+
|
70 |
+
img_freq = st.radio(
|
71 |
+
"Quanto spesso ho a che fare con le immagini",
|
72 |
+
[
|
73 |
+
"Mai",
|
74 |
+
"Raramente",
|
75 |
+
"Qualche volta",
|
76 |
+
"Spesso",
|
77 |
+
"Sempre"
|
78 |
+
]
|
79 |
+
)
|
80 |
+
|
81 |
+
img_expert = st.radio(
|
82 |
+
"Sono un esperto di immagini",
|
83 |
+
[
|
84 |
+
"1 - Per nulla d'accordo",
|
85 |
+
"2",
|
86 |
+
"3",
|
87 |
+
"4",
|
88 |
+
"5 - Pienamente d'accordo"
|
89 |
+
],
|
90 |
+
horizontal=True
|
91 |
+
)
|
92 |
+
|
93 |
+
ai_expert = st.radio(
|
94 |
+
"Utilizzo strumenti IA per la generazione di immagini (es. Dall-E, Midjourney, Firefly, ecc.)",
|
95 |
+
[
|
96 |
+
"Mai",
|
97 |
+
"Raramente",
|
98 |
+
"Qualche volta",
|
99 |
+
"Spesso",
|
100 |
+
"Sempre"
|
101 |
+
]
|
102 |
+
)
|
103 |
+
|
104 |
+
genova_expert = st.radio(
|
105 |
+
"La mia familiarità con la città di Genova è:",
|
106 |
+
[
|
107 |
+
"1 - Per nulla d'accordo",
|
108 |
+
"2",
|
109 |
+
"3",
|
110 |
+
"4",
|
111 |
+
"5 - Pienamente d'accordo"
|
112 |
+
],
|
113 |
+
horizontal=True
|
114 |
+
)
|
115 |
+
|
116 |
+
genova_freq = st.radio(
|
117 |
+
"Frequento la città di Genova",
|
118 |
+
[
|
119 |
+
"Mai",
|
120 |
+
"Raramente",
|
121 |
+
"Qualche volta",
|
122 |
+
"Spesso",
|
123 |
+
"Sempre"
|
124 |
+
]
|
125 |
+
)
|
126 |
+
|
127 |
+
genova_knowledge = st.radio(
|
128 |
+
"Conosco le attrazioni ed i paesaggi della città di Genova",
|
129 |
+
[
|
130 |
+
"1 - Per nulla d'accordo",
|
131 |
+
"2",
|
132 |
+
"3",
|
133 |
+
"4",
|
134 |
+
"5 - Pienamente d'accordo"
|
135 |
+
],
|
136 |
+
horizontal=True
|
137 |
+
)
|
138 |
+
|
139 |
+
genova_thoughts = st_tags(
|
140 |
+
label="Quando penso a Genova mi immagino:",
|
141 |
+
text="Premere invio per aggiungere un nuovo elemento",
|
142 |
+
value=[],
|
143 |
+
maxtags=-1)
|
144 |
+
# thoughts = st.multiselect(
|
145 |
+
# "Quando penso a Genova mi immagino:",
|
146 |
+
# [
|
147 |
+
# "ciao"
|
148 |
+
# ],
|
149 |
+
# placeholder="Scrivi le opzioni"
|
150 |
+
# )
|
151 |
+
|
152 |
+
submit = st.form_submit_button("Salva", on_click=store_user)
|
153 |
+
|
154 |
+
if submit:
|
155 |
+
st.success("Salvataggio completato")
|
156 |
+
|
157 |
+
st.page_link("pages/annotation.py", label="Continua")
|
pages/login.py
CHANGED
@@ -1,10 +1,28 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
st.title("Studio sulla City Identity")
|
5 |
|
6 |
-
st.
|
|
|
|
|
|
|
7 |
|
8 |
-
st.text_input("
|
|
|
|
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
1 |
+
import pickle as pkl
|
2 |
import streamlit as st
|
3 |
|
4 |
+
USER_FILE = "users.pkl"
|
5 |
+
|
6 |
+
try:
|
7 |
+
with open(USER_FILE, "rb") as file:
|
8 |
+
users = pkl.load(file)
|
9 |
+
except Exception as exc:
|
10 |
+
users = []
|
11 |
+
|
12 |
+
st.session_state["users"] = users
|
13 |
|
14 |
st.title("Studio sulla City Identity")
|
15 |
|
16 |
+
st.markdown("""Per condurre l'esperimento, ti sarà attribuito un nickname univoco ed anonimo
|
17 |
+
per salvare lo stato d'avanzamento dello studio.
|
18 |
+
Il nickname è composto dalle prime tre lettere del nome di tua madre, le prime tre lettere nel nome di tuo padre
|
19 |
+
e le prime due cifre della data del tuo compleanno.""")
|
20 |
|
21 |
+
nickname = st.text_input("Inserisci il tuo nickname")
|
22 |
+
st.session_state["user"] = {}
|
23 |
+
st.session_state["user"]["nickname"] = nickname
|
24 |
|
25 |
+
if nickname in users:
|
26 |
+
st.page_link("pages/annotation.py", label="Comincia")
|
27 |
+
else:
|
28 |
+
st.page_link("pages/instructions.py", label="Comincia")
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit-tags
|
2 |
+
datasets
|
3 |
+
pandas
|