Delete app.py
Browse files
app.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
-
import gradio as gr
|
| 3 |
-
import pandas as pd
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
models = []
|
| 7 |
-
models.append("MoritzLaurer/mDeBERTa-v3-base-mnli-xnli") ### 0
|
| 8 |
-
models.append("MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli") ### 1 Fast
|
| 9 |
-
models.append("MoritzLaurer/deberta-v3-large-zeroshot-v2.0") ### 2
|
| 10 |
-
models.append("facebook/bart-large-mnli") ### 3
|
| 11 |
-
models.append("MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7") ### 4
|
| 12 |
-
|
| 13 |
-
model = models[1]
|
| 14 |
-
#classifier = pipeline("zero-shot-classification", model=model)
|
| 15 |
-
|
| 16 |
-
def coding(model, text, codetext):
|
| 17 |
-
classifier = pipeline("zero-shot-classification", model=model)
|
| 18 |
-
codelist = codetext.split(',')
|
| 19 |
-
output = classifier(text, codelist, multi_label=True)
|
| 20 |
-
return output
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def read_excel_file(file):
|
| 25 |
-
# Read the Excel file
|
| 26 |
-
data = pd.read_excel(file.name, sheet_name="codelist")
|
| 27 |
-
return data
|
| 28 |
-
|
| 29 |
-
iface = gr.Interface(
|
| 30 |
-
fn=coding,
|
| 31 |
-
inputs=[
|
| 32 |
-
# gr.HTML(
|
| 33 |
-
# "<a style='font-size:120%' href='https://huggingface.co/models?pipeline_tag=zero-shot-classification&language=zh&sort=downloads'>https://huggingface.co/models</a>"
|
| 34 |
-
# ),
|
| 35 |
-
gr.Radio(
|
| 36 |
-
[
|
| 37 |
-
"facebook/bart-large-mnli",
|
| 38 |
-
"MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
|
| 39 |
-
"MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
|
| 40 |
-
"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
|
| 41 |
-
"MoritzLaurer/deberta-v3-large-zeroshot-v2.0",
|
| 42 |
-
#"joeddav/xlm-roberta-large-xnli"
|
| 43 |
-
],
|
| 44 |
-
#min_width=200,
|
| 45 |
-
#scale=2,
|
| 46 |
-
value="facebook/bart-large-mnli",
|
| 47 |
-
label="Model"
|
| 48 |
-
),
|
| 49 |
-
gr.TextArea(
|
| 50 |
-
label='Comment',
|
| 51 |
-
value='感覺性格溫和,適合香港人,特別係亞洲人的肌膚,不足之處就是感覺很少有優惠,價錢都比較貴'
|
| 52 |
-
),
|
| 53 |
-
gr.Textbox(
|
| 54 |
-
label='Code list',
|
| 55 |
-
value='非常好/很好/好滿意,價錢合理/實惠/不太貴/親民/價格適中/價格便宜/價錢大眾化,價錢貴/不合理/比日本台灣貴/可以再平d/Sasa 卓悅買會平啲'
|
| 56 |
-
)
|
| 57 |
-
],
|
| 58 |
-
outputs=[
|
| 59 |
-
#gr.Textbox(label='Result')
|
| 60 |
-
gr.JSON()
|
| 61 |
-
#gr.BarPlot()
|
| 62 |
-
],
|
| 63 |
-
title="NuanceTree Coding Test",
|
| 64 |
-
description="Test Zero-Shot Classification",
|
| 65 |
-
allow_flagging='never'
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
-
# #iface.clear
|
| 69 |
-
#gr.close_all()
|
| 70 |
-
#iface.launch(server_name="0.0.0.0", server_port=7777)
|
| 71 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|