cofeg commited on
Commit
219e79a
·
verified ·
1 Parent(s): 0f90cb6

feat: add description to gradio interface

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -2,10 +2,13 @@ import os
2
  from huggingface_hub import InferenceClient
3
  import gradio as gr
4
  import re
 
 
 
5
 
6
- hugging_face_model_path = "cofeg/Finetuned-Xunzi-Qwen2-1.5B-for-ancient-text-generation"
7
-
8
- client = InferenceClient(model=hugging_face_model_path, token=os.getenv('HUGGING_FACE_TOKEN'))
9
 
10
  def split_and_generate(modern_text):
11
  # Split the input text into sentences for the model is trained on sentence pairs
@@ -19,6 +22,9 @@ def split_and_generate(modern_text):
19
  yield responses
20
 
21
  demo = gr.Interface(fn=split_and_generate,
22
- inputs=[gr.Textbox(label="现代文", lines=10)],
23
- outputs=[gr.Textbox(label="古文", lines=10)])
 
 
 
24
  demo.launch()
 
2
  from huggingface_hub import InferenceClient
3
  import gradio as gr
4
  import re
5
+ import sys
6
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7
+ from config.config import *
8
 
9
+ os.environ['CURL_CA_BUNDLE'] = '' # Avoid SSL error
10
+ hugging_face_model_path = HUGGING_FACE_USER_NAME + "/" + MERGED_MODEL_NAME
11
+ client = InferenceClient(model=hugging_face_model_path, token=HUGGING_FACE_TOKEN)
12
 
13
  def split_and_generate(modern_text):
14
  # Split the input text into sentences for the model is trained on sentence pairs
 
22
  yield responses
23
 
24
  demo = gr.Interface(fn=split_and_generate,
25
+ inputs=[gr.Textbox(label="现代文", lines=10)],
26
+ outputs=[gr.Textbox(label="古文", lines=10)],
27
+ title="现代文转古文大模型",
28
+ description="请在左边对话框输入你要转换的现代文并点击“Submit”按钮,耐心等待一两分钟,右边的对话框将显示转换后的古文。\n由于训练数据来源于《徐霞客游记》,故对游记类文字转换效果较好。"
29
+ )
30
  demo.launch()