Spaces:
Sleeping
Sleeping
| 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() | |