File size: 1,246 Bytes
a191ded |
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 |
import gradio as gr
import pickle
def load_and_display_data():
"""Loads the pickled data and formats it for display."""
try:
with open('canteen_surplus_data.pkl', 'rb') as f:
data = pickle.load(f)
# Format the dictionary for better display in Gradio
formatted_output = ""
for canteen_id, info in data.items():
formatted_output += f"Canteen ID: {canteen_id}\n"
formatted_output += f" Canteen Name: {info['canteen_name']}\n"
formatted_output += f" Predicted Surplus: {info['predicted_surplus']}\n"
formatted_output += f" NGO Requirement: {info['ngo_requirement']}\n"
formatted_output += "-" * 20 + "\n"
return formatted_output
except FileNotFoundError:
return "Error: canteen_surplus_data.pkl not found."
except Exception as e:
return f"An error occurred: {e}"
# Create a Gradio interface to display the data
iface = gr.Interface(
fn=load_and_display_data,
inputs=None, # No input needed to display the data
outputs="text",
title="Canteen Surplus and NGO Requirements",
description="Displays the predicted surplus units and NGO requirements for each canteen."
)
iface.launch()
|