Spaces:
Sleeping
Sleeping
File size: 1,082 Bytes
98998d9 c5480cd bd17397 98998d9 bd17397 c5480cd 98998d9 c5480cd 98998d9 bd17397 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from transformers import pipeline
# 日本語T5モデルをロード(サイズは base。必要なら large に変更可)
pipe = pipeline("text2text-generation", model="sonoisa/t5-base-japanese")
def format_report(memo):
if not memo.strip():
return "⚠️ 入力が空です。事故メモを入力してください。"
# プロンプトを工夫して「報告書風」に整えるよう指示
input_text = f"以下のメモを特養での事故報告書の文章に整えてください。\n{memo}"
try:
result = pipe(input_text, max_length=512, do_sample=False)
return result[0]["generated_text"]
except Exception as e:
return f"⚠️ エラーが発生しました: {str(e)}"
iface = gr.Interface(
fn=format_report,
inputs=gr.Textbox(lines=8, placeholder="ここに事故のメモを入力してください"),
outputs="text",
title="事故報告書整理AI",
description="介護現場での事故メモを、報告書形式の文章に整えます。"
)
iface.launch()
|