import gradio as gr import pandas as pd # Read the CSV file containing the vehicle details df = pd.read_csv("all_vehicle_details.csv") # Get unique vehicle numbers from the DataFrame vehicle_numbers = df["Registration Number"].unique() # Create a Dropdown component for vehicle number selection dropdown = gr.Dropdown( choices=list(vehicle_numbers), label="Select or type vehicle number" ) # Function to display vehicle details based on the input vehicle number def display_vehicle_details(vehicle_number): # Convert the input vehicle number to uppercase vehicle_number = vehicle_number.upper() # Search for the corresponding row in the DataFrame vehicle_info = df[df["Registration Number"].str.upper() == vehicle_number] # If vehicle info found, return details as HTML table if not vehicle_info.empty: details = "" for index, row in vehicle_info.iterrows(): details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "" details += "
Registration Number:" + str(row['Registration Number']) + "
RC Status:" + str(row['RC Status']) + "
Vehicle Class:" + str(row['Vehicle Class']) + "
Fuel Type:" + str(row['Fuel Type']) + "
Model Name:" + str(row['Model Name']) + "
Manufacturer Name:" + str(row['Manufacturer Name']) + "
Registering Authority:" + str( row['Registering Authority']) + "
Owner's Name:" + str(row["Owner's Name"]) + "
Registration Date:" + str(row['Registration Date']) + "
Fitness/Registration Validity:" + str( row['Fitness/Registration Validity']) + "
MV Tax Validity:" + str(row['MV Tax Validity']) + "
PUCC Validity:" + str(row['PUCC Validity']) + "
Insurance Company:" + str(row['Insurance Company']) + "
Insurance Validity:" + str(row['Insurance Validity']) + "
Policy Number:" + str(row['Policy Number']) + "
" else: details = "Vehicle not found" return details # Create a Gradio interface iface = gr.Interface( fn=display_vehicle_details, inputs=dropdown, outputs="html", title="Vehicle Details", description="Select or type the vehicle number to view its details." ) # Launch the interface iface.launch()