|
|
|
"""Application.ipynb |
|
|
|
Automatically generated by Colaboratory. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/148du8431_JkTaH-totdocC2aUXzOWimL |
|
""" |
|
|
|
import gradio as gr |
|
from transformers import BertTokenizer, TFBertForSequenceClassification |
|
import tensorflow as tf |
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pipeline= pipeline(task="text-classification", model="https://huggingface.co/spaces/Kleo/Sarcasm/blob/main/fine-tuned-bert-gr.h5") |
|
def check_sarcasm(sentence): |
|
|
|
|
|
|
|
|
|
pred_label=pipeline(sentence) |
|
|
|
if pred_label == 1: |
|
return "Sarcastic" |
|
else: |
|
return "Not sarcastic" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=check_sarcasm, |
|
inputs="text", |
|
outputs="text", |
|
title="Sarcasm Detection", |
|
server_name="0.0.0.0", |
|
description="Enter a headline from the Greek news and check if it's sarcastic." |
|
) |
|
|
|
|
|
iface.launch() |
|
|
|
|