Spaces:
Sleeping
Sleeping
| from simpletransformers.classification import ClassificationModel | |
| import gradio as gr | |
| import pandas as pd | |
| import numpy as np | |
| def predict(text): | |
| model_path = "/content/drive/MyDrive/bert_model" | |
| model = ClassificationModel('bert', model_path, use_cuda=False) | |
| prediction, _ = model.predict([text]) | |
| return result_predict(prediction[0]) | |
| def result_predict(num): | |
| if num == 4: | |
| return 'OTHER' | |
| elif num == 1: | |
| return 'RACIST' | |
| elif num == 0: | |
| return 'INSULT' | |
| elif num == 3: | |
| return 'PROFANITY' | |
| elif num == 2: | |
| return 'SEXIST' | |
| # Gradio arayüzünü oluştur | |
| iface = gr.Interface( | |
| fn=predict, # Kullanıcıdan alınan metni modelinize ileten fonksiyon | |
| inputs=gr.Textbox(), # Kullanıcıdan metin girişi alın | |
| outputs=gr.Textbox(), # Model çıktısını görüntülemek için metin kutusu | |
| live=True, | |
| title='Yorum Tespiti', | |
| css='''span{text-transform: uppercase} p{text-align: center}''' | |
| ) | |
| # Gradio arayüzünü başlat | |
| iface.launch() | |