jslin09 commited on
Commit
351b9e5
1 Parent(s): 916ef74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -28
app.py CHANGED
@@ -1,37 +1,22 @@
1
  import gradio as gr
 
2
 
3
- title = "Legal Document Drafting"
4
 
5
- drafting_examples = [
 
 
 
 
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
- stt_demo = gr.Interface.load(
28
- "huggingface/jslin09/bloom-560m-finetuned-fraud",
29
- title=None,
30
- inputs="森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,",
31
- description="Let me try to guess what you're saying!",
32
  )
33
 
34
- demo = gr.TabbedInterface([drafting_demo, stt_demo], ["Verdicts Drafting", "Speech-to-text"])
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()