Pref_Im_2 / src /streamlit_app.py
PedroC11's picture
Update src/streamlit_app.py
e536da4 verified
Raw
History Blame
1.23 kB
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")