admin commited on
Commit
b0b394a
·
1 Parent(s): 4bb8e93
modules/data.py CHANGED
@@ -161,38 +161,45 @@ def data_converter(tab_cfgs=["jsonl ⇆ csv", "json ⇆ csv", "json ⇆ jsonl"])
161
  outputs=[status_bar, output_file, data_viewer],
162
  )
163
 
164
- gr.Markdown(
165
- f"""
166
- ## {_L('支持的 JSON 格式')}
167
- ```
168
- [
169
- {{
170
- "key1": "val11",
171
- "key2": "val12",
172
- ...
173
- }},
174
- {{
175
- "key1": "val21",
176
- "key2": "val22",
177
- ...
178
- }},
179
- ...
180
- ]
181
- ```
182
- ## {_L('支持的 JSON Lines 格式')}
183
- ```
184
- {{"key1": "val11", "key2": "val12", ...}}
185
- {{"key1": "val21", "key2": "val22", ...}}
186
- ...
187
- ```
188
- ## {_L('支持的 CSV 格式')}
189
- ```
190
- key1, key2, ...
191
- val11, val12, ...
192
- val21, val22, ...
193
- ...
194
- ```
195
- """
196
- )
 
 
 
 
 
 
 
197
 
198
  return data
 
161
  outputs=[status_bar, output_file, data_viewer],
162
  )
163
 
164
+ with gr.Row():
165
+ with gr.Column():
166
+ gr.Markdown(
167
+ f"""
168
+ ## {_L('支持的 JSON Lines 格式')}
169
+ ```
170
+ {{"key1": "val11", "key2": "val12", ...}}
171
+ {{"key1": "val21", "key2": "val22", ...}}
172
+ ...
173
+ ```
174
+ ## {_L('支持的 CSV 格式')}
175
+ ```
176
+ key1, key2, ...
177
+ val11, val12, ...
178
+ val21, val22, ...
179
+ ...
180
+ ```
181
+ """
182
+ )
183
+
184
+ with gr.Column():
185
+ gr.Markdown(
186
+ f"""
187
+ ## {_L('支持的 JSON 格式')}
188
+ ```
189
+ [
190
+ {{
191
+ "key1": "val11",
192
+ "key2": "val12",
193
+ ...
194
+ }},
195
+ {{
196
+ "key1": "val21",
197
+ "key2": "val22",
198
+ ...
199
+ }},
200
+ ...
201
+ ]
202
+ ```"""
203
+ )
204
 
205
  return data
modules/exif.py CHANGED
@@ -13,11 +13,10 @@ ZH2EN = {
13
  "导出原格式": "Export original format",
14
  "下载清理 EXIF 后的图片": "Download cleaned picture",
15
  "批量处理": "Batch processor",
16
- "上传包含多图片的 zip 压缩包": "Upload pictures zip",
17
  "导出原格式": "Export original format",
18
  "下载清理 EXIF 后的多图片压缩包": "Download cleaned pictures",
19
  "EXIF 列表": "EXIF list",
20
- "上传包含多图片的 zip 压缩包时确保上传进度至 100% 后再提交": "When uploading pictures zip, please make sure the zip is completely uploaded before clicking Submit",
21
  "状态栏": "Status",
22
  }
23
 
@@ -160,7 +159,9 @@ def clexif():
160
  fn=batch_infer,
161
  inputs=[
162
  gr.File(
163
- label=_L("上传包含多图片的 zip 压缩包"),
 
 
164
  file_types=[".zip"],
165
  ),
166
  gr.Checkbox(
@@ -176,9 +177,6 @@ def clexif():
176
  ),
177
  gr.Dataframe(label=_L("EXIF 列表")),
178
  ],
179
- description=_L(
180
- "上传包含多图片的 zip 压缩包时确保上传进度至 100% 后再提交"
181
- ),
182
  flagging_mode="never",
183
  )
184
 
 
13
  "导出原格式": "Export original format",
14
  "下载清理 EXIF 后的图片": "Download cleaned picture",
15
  "批量处理": "Batch processor",
16
+ "上传包含多图片的 zip 压缩包(确保上传进度至 100% 后再提交)": "Upload pictures zip(Please ensure the zip is completely uploaded before clicking submit)",
17
  "导出原格式": "Export original format",
18
  "下载清理 EXIF 后的多图片压缩包": "Download cleaned pictures",
19
  "EXIF 列表": "EXIF list",
 
20
  "状态栏": "Status",
21
  }
22
 
 
159
  fn=batch_infer,
160
  inputs=[
161
  gr.File(
162
+ label=_L(
163
+ "上传包含多图片的 zip 压缩包(确保上传进度至 100% 后再提交)"
164
+ ),
165
  file_types=[".zip"],
166
  ),
167
  gr.Checkbox(
 
177
  ),
178
  gr.Dataframe(label=_L("EXIF 列表")),
179
  ],
 
 
 
180
  flagging_mode="never",
181
  )
182
 
modules/gif.py CHANGED
@@ -5,14 +5,12 @@ from PIL import Image, ImageSequence
5
  from moviepy.editor import VideoFileClip
6
  from utils import clean_dir, TMP_DIR, LANG
7
 
8
-
9
  ZH2EN = {
10
- "上传视频": "Upload video",
11
  "倍速": "Speed",
12
  "状态栏": "Status",
13
  "文件名": "Filename",
14
  "下载动图": "Download GIF",
15
- "请确保视频上传完整后再点击提交,若时长大于五秒可先在线裁剪": "Please make sure the video is completely uploaded before clicking Submit, you can crop it online first if the video size is >5s",
16
  }
17
 
18
 
@@ -75,10 +73,19 @@ def infer(video_path: str, speed: float, target_w=640, cache=f"{TMP_DIR}/gif"):
75
 
76
 
77
  def video2gif():
 
 
 
 
 
78
  return gr.Interface(
79
  fn=infer,
80
  inputs=[
81
- gr.Video(label=_L("上传视频")),
 
 
 
 
82
  gr.Slider(label=_L("倍速"), minimum=0.5, maximum=2.0, step=0.25, value=1.0),
83
  ],
84
  outputs=[
@@ -86,13 +93,7 @@ def video2gif():
86
  gr.Textbox(label=_L("文件名"), show_copy_button=True),
87
  gr.Image(label=_L("下载动图"), type="filepath", show_share_button=False),
88
  ],
89
- description=_L("请确保视频上传完整后再点击提交,若时长大于五秒可先在线裁剪"),
90
  flagging_mode="never",
91
- examples=[
92
- [
93
- "https://www.modelscope.cn/studio/Genius-Society/online_tools/resolve/master/examples/herta.mp4",
94
- 2,
95
- ]
96
- ],
97
  cache_examples=False,
98
  )
 
5
  from moviepy.editor import VideoFileClip
6
  from utils import clean_dir, TMP_DIR, LANG
7
 
 
8
  ZH2EN = {
9
+ "上传视频(请确保上传完整后再点击提交,若时长大于五秒可先在线裁剪)": "Upload video(Please ensure the video is completely uploaded before clicking submit, you can crop it online to less than 5s)",
10
  "倍速": "Speed",
11
  "状态栏": "Status",
12
  "文件名": "Filename",
13
  "下载动图": "Download GIF",
 
14
  }
15
 
16
 
 
73
 
74
 
75
  def video2gif():
76
+ example = (
77
+ "https://www.modelscope.cn/studio/Genius-Society/online_tools/resolve/master"
78
+ if LANG
79
+ else "."
80
+ )
81
  return gr.Interface(
82
  fn=infer,
83
  inputs=[
84
+ gr.Video(
85
+ label=_L(
86
+ "上传视频(请确保上传完整后再点击提交,若时长大于五秒可先在线裁剪)"
87
+ )
88
+ ),
89
  gr.Slider(label=_L("倍速"), minimum=0.5, maximum=2.0, step=0.25, value=1.0),
90
  ],
91
  outputs=[
 
93
  gr.Textbox(label=_L("文件名"), show_copy_button=True),
94
  gr.Image(label=_L("下载动图"), type="filepath", show_share_button=False),
95
  ],
 
96
  flagging_mode="never",
97
+ examples=[[f"{example}/examples/herta.mp4", 2]],
 
 
 
 
 
98
  cache_examples=False,
99
  )
modules/github.py CHANGED
@@ -10,9 +10,9 @@ ZH2EN = {
10
  "输入仓库名": "Repo name",
11
  "输入 personal access token": "Personal access token",
12
  "发布标签": "Release tag",
13
- "发布名": "Release title",
14
  "发布描述": "Describe this release",
15
- "上传发布文件(可多选)": "Binary File(s)",
16
  "状态栏": "Status",
17
  "上传文件创建一个新的 GitHub 发布": "Upload binary file(s) to create a new GitHub release.",
18
  }
@@ -86,12 +86,14 @@ def github_release_creator():
86
  placeholder=_L("输入 personal access token"),
87
  type="password",
88
  ),
89
- gr.Textbox(label=_L("发布标签")),
90
- gr.Textbox(label=_L("发布名")),
91
- gr.TextArea(label=_L("发布描述")),
 
 
 
92
  gr.File(label=_L("上传发布文件(可多选)"), file_count="multiple"),
93
  ],
94
  outputs=gr.TextArea(label=_L("状态栏"), show_copy_button=True),
95
- description=_L("上传文件创建一个新的 GitHub 发布"),
96
  flagging_mode="never",
97
  )
 
10
  "输入仓库名": "Repo name",
11
  "输入 personal access token": "Personal access token",
12
  "发布标签": "Release tag",
13
+ "发布标题": "Release title",
14
  "发布描述": "Describe this release",
15
+ "上传发布文件(可多选)": "Binary file(s)",
16
  "状态栏": "Status",
17
  "上传文件创建一个新的 GitHub 发布": "Upload binary file(s) to create a new GitHub release.",
18
  }
 
86
  placeholder=_L("输入 personal access token"),
87
  type="password",
88
  ),
89
+ gr.Textbox(label=_L("发布标签"), placeholder="Release tag"),
90
+ gr.Textbox(label=_L("发布标题"), placeholder="Release title"),
91
+ gr.TextArea(
92
+ label=_L("发布描述"),
93
+ placeholder=_L("上传文件创建一个新的 GitHub 发布"),
94
+ ),
95
  gr.File(label=_L("上传发布文件(可多选)"), file_count="multiple"),
96
  ],
97
  outputs=gr.TextArea(label=_L("状态栏"), show_copy_button=True),
 
98
  flagging_mode="never",
99
  )
modules/qr.py CHANGED
@@ -37,12 +37,11 @@ def qrcode():
37
  fn=infer,
38
  inputs=[
39
  gr.Slider(35, 1000, 217, label=_L("二维码输出尺寸")),
40
- gr.Textbox(label=_L("输入文本")),
41
  ],
42
  outputs=[
43
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
44
  gr.Image(label=_L("输出二维码"), show_share_button=False),
45
  ],
46
- description=_L("输入文字在线生成二维码"),
47
  flagging_mode="never",
48
  )
 
37
  fn=infer,
38
  inputs=[
39
  gr.Slider(35, 1000, 217, label=_L("二维码输出尺寸")),
40
+ gr.Textbox(label=_L("输入文本"), placeholder=_L("输入文字在线生成二维码")),
41
  ],
42
  outputs=[
43
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
44
  gr.Image(label=_L("输出二维码"), show_share_button=False),
45
  ],
 
46
  flagging_mode="never",
47
  )
modules/rct.py CHANGED
@@ -6,11 +6,10 @@ from utils import clean_dir, TMP_DIR, LANG
6
 
7
  ZH2EN = {
8
  "输入参与者数量": "Number of participants",
9
- "输入分组比率": "Grouping ratio",
10
  "状态栏": "Status",
11
  "下载随机分组数据 CSV": "Download data CSV",
12
  "随机分组数据预览": "Data preview",
13
- "输入参与者数量和分组比率,格式为用:隔开的数字,生成随机分组数据。": "Enter the number of participants and the grouping ratio in the format of numbers separated by : to generate randomized controlled trial.",
14
  }
15
 
16
 
@@ -81,15 +80,15 @@ def rct_generator():
81
  fn=infer,
82
  inputs=[
83
  gr.Number(label=_L("输入参与者数量"), value=10),
84
- gr.Textbox(label=_L("输入分组比率"), value="8:1:1"),
 
 
 
85
  ],
86
  outputs=[
87
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
88
  gr.File(label=_L("下载随机分组数据 CSV")),
89
  gr.Dataframe(label=_L("随机分组数据预览")),
90
  ],
91
- description=_L(
92
- "输入参与者数量和分组比率,格式为用:隔开的数字,生成随机分组数据。"
93
- ),
94
  flagging_mode="never",
95
  )
 
6
 
7
  ZH2EN = {
8
  "输入参与者数量": "Number of participants",
9
+ "输入分组比率(格式为用:隔开的数字,生成随机分组数据)": "Grouping ratio(Numbers separated by : to generate randomized controlled trial)",
10
  "状态栏": "Status",
11
  "下载随机分组数据 CSV": "Download data CSV",
12
  "随机分组数据预览": "Data preview",
 
13
  }
14
 
15
 
 
80
  fn=infer,
81
  inputs=[
82
  gr.Number(label=_L("输入参与者数量"), value=10),
83
+ gr.Textbox(
84
+ label=_L("输入分组比率(格式为用:隔开的数字,生成随机分组数据)"),
85
+ value="8:1:1",
86
+ ),
87
  ],
88
  outputs=[
89
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
90
  gr.File(label=_L("下载随机分组数据 CSV")),
91
  gr.Dataframe(label=_L("随机分组数据预览")),
92
  ],
 
 
 
93
  flagging_mode="never",
94
  )
modules/smtp.py CHANGED
@@ -7,12 +7,12 @@ ZH2EN = {
7
  "标题": "Title",
8
  "测试标题": "Test title",
9
  "正文": "Content",
10
- "测试正文": "Test content",
11
  "发信人昵称": "Sender name",
12
  "测试昵称": "Test nickname",
13
  "发信人邮箱": "From email",
14
  "应用密钥": "API key",
15
- "SMTP服务器": "SMTP host",
16
  "端口": "Port",
17
  "发送状态": "Status",
18
  }
@@ -55,13 +55,13 @@ def smtp_tester():
55
  return gr.Interface(
56
  fn=infer,
57
  inputs=[
58
- gr.Textbox(label=_L("收信人邮箱")),
59
  gr.Textbox(label=_L("标题"), value=_L("测试标题")),
60
- gr.TextArea(label=_L("正文"), value=_L("测试正文")),
61
  gr.Textbox(label=_L("发信人昵称"), value=_L("测试昵称")),
62
- gr.Textbox(label=_L("发信人邮箱")),
63
- gr.Textbox(label=_L("应用密钥")),
64
- gr.Textbox(label=_L("SMTP服务器"), value="smtp.163.com"),
65
  gr.Slider(label=_L("端口"), minimum=0, maximum=65535, step=1, value=25),
66
  ],
67
  outputs=gr.TextArea(label=_L("发送状态"), show_copy_button=True),
 
7
  "标题": "Title",
8
  "测试标题": "Test title",
9
  "正文": "Content",
10
+ "SMTP 在线测试工具": "SMTP online tester",
11
  "发信人昵称": "Sender name",
12
  "测试昵称": "Test nickname",
13
  "发信人邮箱": "From email",
14
  "应用密钥": "API key",
15
+ "SMTP 服务器": "SMTP host",
16
  "端口": "Port",
17
  "发送状态": "Status",
18
  }
 
55
  return gr.Interface(
56
  fn=infer,
57
  inputs=[
58
+ gr.Textbox(label=_L("收信人邮箱"), placeholder="Recipient"),
59
  gr.Textbox(label=_L("标题"), value=_L("测试标题")),
60
+ gr.TextArea(label=_L("正文"), value=_L("SMTP 在线测试工具")),
61
  gr.Textbox(label=_L("发信人昵称"), value=_L("测试昵称")),
62
+ gr.Textbox(label=_L("发信人邮箱"), placeholder="Sender"),
63
+ gr.Textbox(label=_L("应用密钥"), placeholder="SMTP password"),
64
+ gr.Textbox(label=_L("SMTP 服务器"), value="smtp.163.com"),
65
  gr.Slider(label=_L("端口"), minimum=0, maximum=65535, step=1, value=25),
66
  ],
67
  outputs=gr.TextArea(label=_L("发送状态"), show_copy_button=True),
modules/url.py CHANGED
@@ -4,11 +4,11 @@ import gradio as gr
4
  from utils import is_valid_url, HEADER, LANG
5
 
6
  ZH2EN = {
7
- "输入长 URL": "Input a long URL",
8
- "输入待变短的长 URL": "Input a long URL",
9
  "选择 API 提供商": "Select an API provider",
10
- "输出短 URL": "Output short URL",
11
- "将长 URL 转换为短的、易于共享的链接": "Convert long urls into short, easy-to-share links",
 
12
  "状态栏": "Status",
13
  }
14
 
@@ -20,8 +20,7 @@ def _L(zh_txt: str):
20
  return zh_txt
21
 
22
 
23
- def noxlink(longUrl: str):
24
- domain = "https://noxlink.net"
25
  api = f"{domain}/zh-CN/shorten"
26
  response = requests.post(api, json={"longUrl": longUrl}, headers=HEADER)
27
  if response.status_code == 200:
@@ -47,7 +46,7 @@ def monojson(longUrl: str):
47
  # outer func
48
  def infer(longUrl: str, tool: str):
49
  status = "Success"
50
- shortUrl = ""
51
  try:
52
  if tool == "monojson":
53
  shortUrl = monojson(longUrl)
@@ -57,19 +56,22 @@ def infer(longUrl: str, tool: str):
57
  raise ValueError("请选择一个 API 提供商!")
58
 
59
  if is_valid_url(shortUrl):
60
- shortUrl = f'<a href="{shortUrl}" target="_blank">{shortUrl}</a>'
61
 
62
  except Exception as e:
63
  status = f"{e}"
64
 
65
- return status, shortUrl
66
 
67
 
68
  def url_shortner():
69
  return gr.Interface(
70
  fn=infer,
71
  inputs=[
72
- gr.Textbox(label=_L("输入长 URL"), placeholder=_L("输入待变短的长 URL")),
 
 
 
73
  gr.Dropdown(
74
  choices=["noxlink", "monojson"],
75
  label=_L("选择 API 提供商"),
@@ -78,13 +80,13 @@ def url_shortner():
78
  ],
79
  outputs=[
80
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
 
81
  gr.HTML(
82
  container=True,
83
  show_label=True,
84
- label=_L("输出短 URL"),
85
  ),
86
  ],
87
- description=_L("将长 URL 转换为短的、易于共享的链接"),
88
  flagging_mode="never",
89
  examples=[
90
  ["https://www.bing.com", "noxlink"],
 
4
  from utils import is_valid_url, HEADER, LANG
5
 
6
  ZH2EN = {
7
+ "输入长链接": "Input a long URL",
 
8
  "选择 API 提供商": "Select an API provider",
9
+ "输出短链接": "Output short URL",
10
+ "预览短链接": "Preview short URL",
11
+ "将长链接转换为短的、易于共享的链接": "Convert long urls into short, easy-to-share links",
12
  "状态栏": "Status",
13
  }
14
 
 
20
  return zh_txt
21
 
22
 
23
+ def noxlink(longUrl: str, domain="https://noxlink.net"):
 
24
  api = f"{domain}/zh-CN/shorten"
25
  response = requests.post(api, json={"longUrl": longUrl}, headers=HEADER)
26
  if response.status_code == 200:
 
46
  # outer func
47
  def infer(longUrl: str, tool: str):
48
  status = "Success"
49
+ shortUrl = preview = None
50
  try:
51
  if tool == "monojson":
52
  shortUrl = monojson(longUrl)
 
56
  raise ValueError("请选择一个 API 提供商!")
57
 
58
  if is_valid_url(shortUrl):
59
+ preview = f'<a href="{shortUrl}" target="_blank">{shortUrl}</a>'
60
 
61
  except Exception as e:
62
  status = f"{e}"
63
 
64
+ return status, shortUrl, preview
65
 
66
 
67
  def url_shortner():
68
  return gr.Interface(
69
  fn=infer,
70
  inputs=[
71
+ gr.Textbox(
72
+ label=_L("输入长链接"),
73
+ placeholder=_L("将长链接转换为短的、易于共享的链接"),
74
+ ),
75
  gr.Dropdown(
76
  choices=["noxlink", "monojson"],
77
  label=_L("选择 API 提供商"),
 
80
  ],
81
  outputs=[
82
  gr.Textbox(label=_L("状态栏"), show_copy_button=True),
83
+ gr.Textbox(label=_L("输出短链接"), show_copy_button=True),
84
  gr.HTML(
85
  container=True,
86
  show_label=True,
87
+ label=_L("预览短链接"),
88
  ),
89
  ],
 
90
  flagging_mode="never",
91
  examples=[
92
  ["https://www.bing.com", "noxlink"],