import gradio as gr from fastai.text.all import * # Or import specific modules as needed # Load the exported model learn = load_learner('riasec-classifier.pkl') # Path to your .pkl file # Define a prediction function def classify_text(text): pred, idx, probs = learn.predict(text) return {learn.dls.vocab[1][i]: float(probs[i]) for i in range(len(probs))} # Create the Gradio interface interface = gr.Interface( fn=classify_text, inputs=gr.Textbox(label="Enter job description"), outputs=gr.Label(num_top_classes=3, label="Prediction"), # Adjust num_top_classes as needed title="RIASEC Predictor", description="Predict the top 3 RIASEC attributes from a job description." ) # Launch the app (run this in your script) interface.launch()