File size: 1,225 Bytes
190629a
 
 
 
 
e536da4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st

# ---- CONFIG ----
st.set_page_config(page_title="Image Preference Study", layout="centered")

st.title("Image Preference Study")
st.write("For each pair, please select which image you prefer.")

# ---- IMAGE PAIRS ----
# Replace with your actual image paths or URLs
image_pairs = [
    ("images/modelA_1.png", "images/modelB_1.png"),
]

results = {}

# ---- LOOP THROUGH PAIRS ----
for i, (imgA, imgB) in enumerate(image_pairs):
    st.markdown(f"### Pair {i+1}")
    col1, col2 = st.columns(2)

    with col1:
        st.image(imgA, caption="Option A", use_container_width=True)
    with col2:
        st.image(imgB, caption="Option B", use_container_width=True)

    choice = st.radio(
        f"Which image do you prefer for Pair {i+1}?",
        ("A", "B"),
        key=f"choice_{i}"
    )
    results[f"pair_{i+1}"] = choice

# ---- SUBMIT ----
if st.button("Submit"):
    st.success("Thank you! Your responses have been recorded.")
    st.write("Here are your selections:")
    st.json(results)

    # Save to file (you could also save to a database)
    with open("resp/responses.txt", "a") as f:
        f.write(str(results) + "\n")