| | 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) |
| | |
| | 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}" |
| |
|
| | |
| | iface = gr.Interface( |
| | fn=load_and_display_data, |
| | inputs=None, |
| | outputs="text", |
| | title="Canteen Surplus and NGO Requirements", |
| | description="Displays the predicted surplus units and NGO requirements for each canteen." |
| | ) |
| |
|
| | iface.launch() |
| |
|