Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,6 @@ def analyze_energy_data(energy_data, location, language):
|
|
49 |
"",
|
50 |
"",
|
51 |
"",
|
52 |
-
"",
|
53 |
0.0
|
54 |
)
|
55 |
|
@@ -73,18 +72,55 @@ def analyze_energy_data(energy_data, location, language):
|
|
73 |
"\n".join(alerts),
|
74 |
f"Your carbon footprint: {carbon_emissions:.2f} kg of CO2. Consider using renewable energy.",
|
75 |
f"AI Recommendation: Optimize usage of AC and lighting based on peak hours to reduce costs and emissions.",
|
76 |
-
savings
|
77 |
)
|
78 |
|
79 |
-
# The rest of the code remains the same
|
80 |
-
|
81 |
# Build the Gradio UI
|
82 |
def build_ui():
|
83 |
with gr.Blocks() as demo:
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
return demo
|
88 |
|
|
|
89 |
demo = build_ui()
|
90 |
demo.launch()
|
|
|
49 |
"",
|
50 |
"",
|
51 |
"",
|
|
|
52 |
0.0
|
53 |
)
|
54 |
|
|
|
72 |
"\n".join(alerts),
|
73 |
f"Your carbon footprint: {carbon_emissions:.2f} kg of CO2. Consider using renewable energy.",
|
74 |
f"AI Recommendation: Optimize usage of AC and lighting based on peak hours to reduce costs and emissions.",
|
75 |
+
savings
|
76 |
)
|
77 |
|
|
|
|
|
78 |
# Build the Gradio UI
|
79 |
def build_ui():
|
80 |
with gr.Blocks() as demo:
|
81 |
+
gr.Markdown("## Energy Consumption Analyzer")
|
82 |
+
|
83 |
+
with gr.Row():
|
84 |
+
energy_data = gr.Textbox(
|
85 |
+
label="Enter Energy Data",
|
86 |
+
placeholder="e.g., AC: 500 kWh\nRefrigerator: 300 kWh",
|
87 |
+
lines=5
|
88 |
+
)
|
89 |
+
location = gr.Textbox(label="Enter Location", placeholder="e.g., Lahore")
|
90 |
+
language = gr.Dropdown(
|
91 |
+
label="Select Language",
|
92 |
+
choices=["English", "Urdu"],
|
93 |
+
value="English"
|
94 |
+
)
|
95 |
+
|
96 |
+
with gr.Row():
|
97 |
+
analyze_button = gr.Button("Analyze")
|
98 |
+
|
99 |
+
with gr.Row():
|
100 |
+
output_bill = gr.Text(label="Estimated Bill")
|
101 |
+
output_recommendations = gr.Text(label="Recommendations")
|
102 |
+
|
103 |
+
with gr.Row():
|
104 |
+
output_weather_tips = gr.Text(label="Weather Tips")
|
105 |
+
output_alerts = gr.Text(label="Alerts")
|
106 |
+
output_carbon_footprint = gr.Text(label="Carbon Footprint")
|
107 |
+
output_ai_recommendation = gr.Text(label="AI Recommendations")
|
108 |
+
|
109 |
+
analyze_button.click(
|
110 |
+
analyze_energy_data,
|
111 |
+
inputs=[energy_data, location, language],
|
112 |
+
outputs=[
|
113 |
+
output_bill,
|
114 |
+
output_recommendations,
|
115 |
+
output_weather_tips,
|
116 |
+
output_alerts,
|
117 |
+
output_carbon_footprint,
|
118 |
+
output_ai_recommendation
|
119 |
+
]
|
120 |
+
)
|
121 |
|
122 |
return demo
|
123 |
|
124 |
+
# Launch the Gradio app
|
125 |
demo = build_ui()
|
126 |
demo.launch()
|