import gradio as gr from setfit import AbsaModel # Load the ABSA model (assuming indo-setfit-absa-bert-base-restaurants is the aspect extraction model) model = AbsaModel.from_pretrained( "pahri/setfit-indo-resto-RM-ibu-imas-polarity", "pahri/setfit-indo-resto-RM-ibu-imas-aspect", spacy_model="id_core_news_trf", ) def analyze_text(text): """ Analyzes the input text using the ABSA model and returns aspects and sentiment. Args: text: The text to be analyzed. Returns: A formatted string containing aspects and sentiment. """ pred = model.predict(text) return pred description = "Analisa Aspek dan Sentimen Review Restoran" title = "Analisa Review Restoran Anda" examples = [["Makanannya enak, tapi pelayanannya lambat."]] interface = gr.Interface( fn=analyze_text, inputs="textbox", outputs="text", description=description, title=title, examples=examples ) interface.launch()