Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 1 |
-
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
model = gr.load("models/fnlp/bart-base-chinese")
|
| 4 |
|
| 5 |
def generate_summary(file):
|
|
|
|
| 6 |
with open(file.name, 'r', encoding='utf-8') as f:
|
| 7 |
text_content = f.read()
|
|
|
|
|
|
|
|
|
|
| 8 |
result = model.predict(text_content)
|
| 9 |
|
| 10 |
return result
|
|
@@ -16,5 +21,5 @@ demo = gr.Interface(
|
|
| 16 |
live=False
|
| 17 |
)
|
| 18 |
|
| 19 |
-
#
|
| 20 |
demo.launch(share=True)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
model = gr.load("models/fnlp/bart-base-chinese")
|
| 5 |
|
| 6 |
def generate_summary(file):
|
| 7 |
+
# 读取上传的文本文件内容
|
| 8 |
with open(file.name, 'r', encoding='utf-8') as f:
|
| 9 |
text_content = f.read()
|
| 10 |
+
print("File Content:", text_content) # 添加此行进行调试
|
| 11 |
+
|
| 12 |
+
# 使用模型进行处理(在这里是摘要生成,你可以替换为你的具体模型处理逻辑)
|
| 13 |
result = model.predict(text_content)
|
| 14 |
|
| 15 |
return result
|
|
|
|
| 21 |
live=False
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# 启动应用并确保配置生效
|
| 25 |
demo.launch(share=True)
|