Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
["闕很大明知金融帳戶之存摺、提款卡及密碼係供自己使用之重要理財工具,"],
|
| 7 |
["森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,"]
|
| 8 |
]
|
| 9 |
-
def greet(name):
|
| 10 |
-
return drafting_examples[1]
|
| 11 |
-
|
| 12 |
-
drafting_demo = gr.Interface.load(
|
| 13 |
-
"huggingface/jslin09/bloom-560m-finetuned-fraud",
|
| 14 |
-
fn=greet,
|
| 15 |
-
title=None,
|
| 16 |
-
examples=drafting_examples,
|
| 17 |
-
inputs=gr.Textbox(
|
| 18 |
-
label="Text 1",
|
| 19 |
-
info="Initial text",
|
| 20 |
-
lines=3,
|
| 21 |
-
value="森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,",
|
| 22 |
-
),
|
| 23 |
-
outputs="text",
|
| 24 |
-
description="Give me something to say!",
|
| 25 |
-
)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
)
|
| 33 |
|
| 34 |
-
demo
|
| 35 |
-
|
| 36 |
-
if __name__ == "__main__":
|
| 37 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
generator = pipeline('text-generation', model='jslin09/bloom-560m-finetuned-fraud')
|
| 5 |
|
| 6 |
+
def generate(text):
|
| 7 |
+
result = generator(text, max_length=30, num_return_sequences=1)
|
| 8 |
+
return result[0]["generated_text"]
|
| 9 |
+
|
| 10 |
+
examples = [
|
| 11 |
["闕很大明知金融帳戶之存摺、提款卡及密碼係供自己使用之重要理財工具,"],
|
| 12 |
["森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,"]
|
| 13 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=generate,
|
| 17 |
+
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
|
| 18 |
+
outputs=gr.outputs.Textbox(label="Generated Text"),
|
| 19 |
+
examples=examples
|
| 20 |
)
|
| 21 |
|
| 22 |
+
demo.launch()
|
|
|
|
|
|
|
|
|