efengx commited on
Commit
94c8109
·
1 Parent(s): 48d3495

fix: update

Browse files
Files changed (2) hide show
  1. app.py +5 -50
  2. fengx_launch.ipynb +7 -7
app.py CHANGED
@@ -4,16 +4,11 @@ from transformers import (
4
  pipeline
5
  )
6
 
7
- os.environ['HUGGING_FACE_HUB_TOKEN']=st.secrets["read_key"]
 
8
 
9
- # albert
10
- # albert_base_chinese_cluecorpussmall=pipeline(task="fill-mask", model="uer/albert-base-chinese-cluecorpussmall")
11
- # roberta
12
- # xlm_roberta_base=pipeline(task="fill-mask", model="xlm-roberta-base")
13
- # xlm_roberta_large=pipeline(task="fill-mask", model="xlm-roberta-large")
14
  # bert
15
  pipe=pipeline(
16
- # model="rjx/chinese-new-text-classification-10200-albert-base-chinese-cluecorpussmall",
17
  model="rjx/rjxai-ahs-en-v1",
18
  )
19
 
@@ -26,13 +21,7 @@ if 'article' not in st.session_state:
26
  if 'result' not in st.session_state:
27
  st.session_state.result=""
28
 
29
- # def charlength():
30
- # if len(st.session_state.article)>=512:
31
- # st.warning("article length is 512")
32
-
33
  def form_article_click():
34
- # st.warning(st.session_state.model_key)
35
- # st.warning(st.session_state.article_key)
36
 
37
  if st.session_state.article_key == "":
38
  st.warning("Need to enter content")
@@ -41,11 +30,8 @@ def form_article_click():
41
  # 截取大于510字符的内容
42
  if len(article)>=2048:
43
  article=article[0: 2048]
44
- # st.info(article)
45
- print(article)
46
  result = pipe(article)
47
  print(result)
48
- # st.session_state.type=result[0]["label"]
49
  if result:
50
  if result[0]["label"]==1:
51
  st.session_state.type="Human writing"
@@ -59,17 +45,9 @@ col1, col2 = st.columns(2)
59
 
60
  with col1:
61
  st.header("input")
62
- with st.form(key="article_form"):
63
- # 模型选择
64
- # option_input = st.selectbox(
65
- # 'select rjx model:(Other model making)',
66
- # ('chinese-new-text-classification-10200-albert-base-chinese-cluecorpussmall', 'other'),
67
- # disabled=True,
68
- # key='model_key',
69
- # # on_change=charlength
70
- # )
71
  # 文本输入
72
- article_input=st.text_area(
73
  'content',
74
  height=270,
75
  key='article_key'
@@ -79,27 +57,4 @@ with col1:
79
 
80
  with col2:
81
  st.header("output")
82
- st.text_input('classification', st.session_state.type, disabled=True)
83
- # st.text_area(
84
- # 'result',
85
- # st.session_state.result,
86
- # height=270,
87
- # disabled=True
88
- # )
89
-
90
-
91
- # st.write('selected classification model:', option)
92
-
93
-
94
- # file_name = st.file_uploader("Upload a hot dog candidate image")
95
-
96
- # if file_name is not None:
97
- # col1, col2 = st.columns(2)
98
-
99
- # image = Image.open(file_name)
100
- # col1.image(image, use_column_width=True)
101
- # predictions = pipeline(image)
102
-
103
- # col2.header("Probabilities")
104
- # for p in predictions:
105
- # col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
 
4
  pipeline
5
  )
6
 
7
+ # os.environ['HUGGING_FACE_HUB_TOKEN']=st.secrets["read_key"]
8
+ os.environ['HUGGING_FACE_HUB_TOKEN']="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"
9
 
 
 
 
 
 
10
  # bert
11
  pipe=pipeline(
 
12
  model="rjx/rjxai-ahs-en-v1",
13
  )
14
 
 
21
  if 'result' not in st.session_state:
22
  st.session_state.result=""
23
 
 
 
 
 
24
  def form_article_click():
 
 
25
 
26
  if st.session_state.article_key == "":
27
  st.warning("Need to enter content")
 
30
  # 截取大于510字符的内容
31
  if len(article)>=2048:
32
  article=article[0: 2048]
 
 
33
  result = pipe(article)
34
  print(result)
 
35
  if result:
36
  if result[0]["label"]==1:
37
  st.session_state.type="Human writing"
 
45
 
46
  with col1:
47
  st.header("input")
48
+ with st.form("article_form"):
 
 
 
 
 
 
 
 
49
  # 文本输入
50
+ st.text_area(
51
  'content',
52
  height=270,
53
  key='article_key'
 
57
 
58
  with col2:
59
  st.header("output")
60
+ st.text_input('classification', key="type", disabled=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fengx_launch.ipynb CHANGED
@@ -33,21 +33,21 @@
33
  },
34
  {
35
  "cell_type": "code",
36
- "execution_count": 18,
37
  "metadata": {},
38
  "outputs": [
39
  {
40
  "name": "stdout",
41
  "output_type": "stream",
42
  "text": [
43
- "Enumerating objects: 7, done.\n",
44
- "Counting objects: 100% (7/7), done.\n",
45
  "Delta compression using up to 8 threads\n",
46
  "Compressing objects: 100% (4/4), done.\n",
47
- "Writing objects: 100% (4/4), 397 bytes | 397.00 KiB/s, done.\n",
48
- "Total 4 (delta 3), reused 0 (delta 0), pack-reused 0\n",
49
- "To https://huggingface.co/spaces/rjx/rjxai_image_identification\n",
50
- " e1e83fc..0271310 main -> main\n"
51
  ]
52
  }
53
  ],
 
33
  },
34
  {
35
  "cell_type": "code",
36
+ "execution_count": 1,
37
  "metadata": {},
38
  "outputs": [
39
  {
40
  "name": "stdout",
41
  "output_type": "stream",
42
  "text": [
43
+ "Enumerating objects: 6, done.\n",
44
+ "Counting objects: 100% (6/6), done.\n",
45
  "Delta compression using up to 8 threads\n",
46
  "Compressing objects: 100% (4/4), done.\n",
47
+ "Writing objects: 100% (4/4), 1.14 KiB | 1.14 MiB/s, done.\n",
48
+ "Total 4 (delta 1), reused 0 (delta 0), pack-reused 0\n",
49
+ "To https://huggingface.co/spaces/rjx/rjxai-ahs-en-v1\n",
50
+ " fa3f0b5..48d3495 main -> main\n"
51
  ]
52
  }
53
  ],