ez326's picture
Upload app.py
b9d560b verified
raw
history blame
6.26 kB
import streamlit as st
# Compact custom CSS for mobile-friendly design and disabled slider styling
css = """
<style>
.criteria-name {
font-size: 14px;
font-weight: bold;
margin-bottom: 2px;
}
.criteria-description {
font-size: 12px;
color: #555;
margin-bottom: 4px;
}
.subcriteria {
margin-bottom: 8px;
padding: 5px 0;
}
.category-header {
margin-top: 10px;
margin-bottom: 4px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #ccc;
padding-bottom: 2px;
}
.app-header {
text-align: center;
margin-bottom: 10px;
font-size: 20px;
}
/* When slider is disabled, change the track and thumb to gray */
div[data-baseweb="slider"][aria-disabled="true"] .Track,
div[data-baseweb="slider"][aria-disabled="true"] .Thumb {
background: #888 !important;
border-color: #888 !important;
}
/* Hide slider tick marks, tick bar, and thumb value */
div[data-baseweb="slider"] .Tick,
div[data-baseweb="slider"] .TickBar,
div[data-testid="stSliderThumbValue"] {
display: none !important;
}
</style>
"""
st.markdown(css, unsafe_allow_html=True)
# Define criteria grouped by category with names and descriptions
criteria = {
"Writing": [
{"name": "Dialogue", "description": "Word choice, realism, subtext, and implications."},
{"name": "Screenwriting", "description": "Structure, plot progression, and narrative choices."},
{"name": "Character Development", "description": "Depth, relatability, motivations, and arcs."},
{"name": "Theme & Symbolism", "description": "Use of deeper meaning, metaphors, and thematic consistency."}
],
"Cinematography": [
{"name": "Camera Work", "description": "Shot composition, stability, movement, and angles."},
{"name": "Lighting", "description": "Contrast, exposure control, and mood-setting."},
{"name": "Color Grading", "description": "Palette consistency, contrast, and emotional tone."},
{"name": "Framing & Aspect Ratio", "description": "Use of space, focus, and visual storytelling."}
],
"Editing & Pacing": [
{"name": "Scene Transitions", "description": "Smoothness, creativity, and effectiveness."},
{"name": "Continuity", "description": "Logical flow and lack of visual inconsistencies."},
{"name": "Pacing", "description": "Balance between slow and fast scenes, engagement level."},
{"name": "Use of Montage", "description": "Storytelling efficiency via edited sequences."}
],
"Sound": [
{"name": "Dialogue Mixing", "description": "Clarity, balance, and intelligibility of speech."},
{"name": "Foley & Sound Effects", "description": "Realism, accuracy, and integration into the world."},
{"name": "Score & Music", "description": "Uniqueness, memorability, and emotional impact."},
{"name": "Spatial Audio & Atmosphere", "description": "Immersion, ambient sound accuracy, and use of silence."}
],
"Directing & Performance": [
{"name": "Directing", "description": "Cohesion of vision, creative choices, and execution."},
{"name": "Acting", "description": "Expression, dialogue delivery, and emotional depth."},
{"name": "Blocking & Staging", "description": "Character positioning, movement, and scene composition."},
{"name": "Action & Stunt Choreography", "description": "Realism, execution, and visual readability."}
],
"Production & Visuals": [
{"name": "Production Design", "description": "Set design, world-building, and authenticity."},
{"name": "Costume & Makeup", "description": "Period accuracy, character enhancement, and detailing."},
{"name": "Practical Effects & Props", "description": "Use of real elements over CGI, believability."},
{"name": "VFX & CGI Integration", "description": "Quality, realism, and seamless blending."}
],
"Engagement & Replay Value": [
{"name": "Plot", "description": "Uniqueness, engagement, predictability, and emotional weight."},
{"name": "Originality", "description": "Avoidance of clichés, fresh storytelling, and innovation."},
{"name": "Rewatchability", "description": "Whether the movie holds up over multiple viewings."},
{"name": "Emotional Impact", "description": "Strength of connection, intensity of response."}
]
}
def calculate_score(ratings):
# Filter out None values (criteria marked as N/A)
valid = [r for r in ratings if r is not None]
if not valid:
return "Please rate at least one criterion."
avg = sum(valid) / len(valid)
# Quadratic scaling: f(x) = (1/18)*x^2 + (19/18)*x - (1/9)
scaled_score = (1/18) * (avg ** 2) + (19/18) * avg - (1/9)
return f"Final Scaled Score: {scaled_score:.2f} / 10"
st.markdown("<h1 class='app-header'>Movie Rating System</h1>", unsafe_allow_html=True)
ratings = []
# Loop over each category and its subcriteria
for group, subcriteria in criteria.items():
st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
for idx, crit in enumerate(subcriteria):
st.markdown(f"""
<div class='subcriteria'>
<div class='criteria-name'>{crit['name']}</div>
<div class='criteria-description'>{crit['description']}</div>
</div>
""", unsafe_allow_html=True)
# Use two columns with a much narrower column for the checkbox
cols = st.columns([3.8, 0.5])
na_key = f"na_{group}_{idx}"
slider_key = f"slider_{group}_{idx}"
na = cols[1].checkbox("N/A", key=na_key)
# Float slider from 1.0 to 7.0 with default value 4.0 and a step of 0.1
rating = cols[0].slider("", 1.0, 7.0, 4.0, step=0.01, key=slider_key, disabled=na)
ratings.append(None if na else rating)
if st.button("Calculate Score"):
result = calculate_score(ratings)
st.markdown(f"<h2 style='text-align:center;'>{result}</h2>", unsafe_allow_html=True)