import gradio as gr sentiment_analysis = gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch() def predict(review_text): # Run the review text through the pipeline result = sentiment_analysis(review_text)[0] # Map the LABEL_0/LABEL_1 to Negative/Positive if result['label'] == 'LABEL_0': result['label'] = 'Negative' elif result['label'] == 'LABEL_1': result['label'] = 'Positive' return result['label'], float(result['score']) iface = gr.Interface(fn=predict, inputs="textbox", outputs=["label", "number"]) iface.launch()