Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
return
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# 日本語T5モデルをロード
|
| 5 |
+
pipe = pipeline("text2text-generation", model="sonoisa/t5-base-japanese")
|
| 6 |
|
| 7 |
+
def format_report(memo):
|
| 8 |
+
# プロンプトに「事故報告書風に整えてください」と指示を入れる
|
| 9 |
+
input_text = f"以下のメモを事故報告書の文章に整えてください:\n{memo}"
|
| 10 |
+
result = pipe(input_text, max_length=512, do_sample=False)
|
| 11 |
+
return result[0]["generated_text"]
|
| 12 |
|
| 13 |
+
iface = gr.Interface(fn=format_report,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="事故報告書整理AI")
|
|
|
|
| 17 |
|
| 18 |
+
iface.launch()
|
|
|