Spaces:
Build error
Build error
| # app.py | |
| import streamlit as st | |
| from transformers import pipeline | |
| # Initialize Hugging Face model for explanation (if needed) | |
| def get_model_info(): | |
| return "Using Hugging Face Transformer Pipeline for advanced logic integration (if necessary)." | |
| def celsius_to_fahrenheit(celsius): | |
| return (celsius * 9/5) + 32 | |
| def fahrenheit_to_celsius(fahrenheit): | |
| return (fahrenheit - 32) * 5/9 | |
| def celsius_to_kelvin(celsius): | |
| return celsius + 273.15 | |
| def kelvin_to_celsius(kelvin): | |
| return kelvin - 273.15 | |
| def fahrenheit_to_kelvin(fahrenheit): | |
| return celsius_to_kelvin(fahrenheit_to_celsius(fahrenheit)) | |
| def kelvin_to_fahrenheit(kelvin): | |
| return celsius_to_fahrenheit(kelvin_to_celsius(kelvin)) | |
| def main(): | |
| st.set_page_config(page_title="Temperature Converter", layout="wide") | |
| st.title("Temperature Conversion Application 🌡") | |
| # Model information section | |
| st.sidebar.title("About the Model") | |
| st.sidebar.info(get_model_info()) | |
| # Adding columns | |
| col1, col2 = st.columns(2) | |
| # Celsius Conversions | |
| with col1: | |
| st.subheader("Celsius Conversions 🌡") | |
| celsius = st.number_input("Enter temperature in Celsius:", format="%.2f") | |
| if st.button("Convert Celsius to Fahrenheit", key="c_to_f"): | |
| st.success(f"{celsius}°C is equal to {celsius_to_fahrenheit(celsius):.2f}°F") | |
| if st.button("Convert Celsius to Kelvin", key="c_to_k"): | |
| st.success(f"{celsius}°C is equal to {celsius_to_kelvin(celsius):.2f}K") | |
| # Fahrenheit and Kelvin Conversions | |
| with col2: | |
| st.subheader("Fahrenheit and Kelvin Conversions 🕶") | |
| fahrenheit = st.number_input("Enter temperature in Fahrenheit:", format="%.2f") | |
| if st.button("Convert Fahrenheit to Celsius", key="f_to_c"): | |
| st.success(f"{fahrenheit}°F is equal to {fahrenheit_to_celsius(fahrenheit):.2f}°C") | |
| if st.button("Convert Fahrenheit to Kelvin", key="f_to_k"): | |
| st.success(f"{fahrenheit}°F is equal to {fahrenheit_to_kelvin(fahrenheit):.2f}K") | |
| kelvin = st.number_input("Enter temperature in Kelvin:", format="%.2f") | |
| if st.button("Convert Kelvin to Celsius", key="k_to_c"): | |
| st.success(f"{kelvin}K is equal to {kelvin_to_celsius(kelvin):.2f}°C") | |
| if st.button("Convert Kelvin to Fahrenheit", key="k_to_f"): | |
| st.success(f"{kelvin}K is equal to {kelvin_to_fahrenheit(kelvin):.2f}°F") | |
| # Scrollbar placeholder | |
| st.markdown("---") | |
| st.text("Scroll below for further details or use the sidebar options.") | |
| if __name__ == "__main__": | |
| main() | |