Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ def random_allocation(participants: int, ratio: list):
|
|
42 |
return filename, pd.DataFrame(sorted_data)
|
43 |
|
44 |
|
45 |
-
def
|
46 |
if os.path.exists(DATA_DIR):
|
47 |
shutil.rmtree(DATA_DIR)
|
48 |
|
@@ -63,19 +63,23 @@ def inference(participants: float, ratios: str):
|
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
gr.Interface(
|
66 |
-
fn=
|
67 |
inputs=[
|
68 |
gr.Number(
|
69 |
label="输入参与者数量 (Number of participants)",
|
70 |
value=10,
|
71 |
),
|
72 |
-
gr.Textbox(
|
|
|
|
|
|
|
|
|
73 |
],
|
74 |
outputs=[
|
75 |
-
gr.
|
76 |
gr.Dataframe(label="随机分组数据预览 (Data preview)"),
|
77 |
],
|
78 |
-
title="
|
79 |
description="输入参与者数量和分组比率,格式为用:隔开的数字,生成随机分组数据。<br>Enter the number of participants and the grouping ratio in the format of numbers separated by : to generate randomized grouping data.",
|
80 |
flagging_mode="never",
|
81 |
).launch()
|
|
|
42 |
return filename, pd.DataFrame(sorted_data)
|
43 |
|
44 |
|
45 |
+
def infer(participants: float, ratios: str):
|
46 |
if os.path.exists(DATA_DIR):
|
47 |
shutil.rmtree(DATA_DIR)
|
48 |
|
|
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
gr.Interface(
|
66 |
+
fn=infer,
|
67 |
inputs=[
|
68 |
gr.Number(
|
69 |
label="输入参与者数量 (Number of participants)",
|
70 |
value=10,
|
71 |
),
|
72 |
+
gr.Textbox(
|
73 |
+
label="输入分组比率 (Grouping ratio)",
|
74 |
+
value="8:1:1",
|
75 |
+
show_copy_button=True,
|
76 |
+
),
|
77 |
],
|
78 |
outputs=[
|
79 |
+
gr.File(label="下载随机分组数据 CSV (Download data CSV)"),
|
80 |
gr.Dataframe(label="随机分组数据预览 (Data preview)"),
|
81 |
],
|
82 |
+
title="随机对照试验随机数生成器 (Randomized Controlled Trial Generator)",
|
83 |
description="输入参与者数量和分组比率,格式为用:隔开的数字,生成随机分组数据。<br>Enter the number of participants and the grouping ratio in the format of numbers separated by : to generate randomized grouping data.",
|
84 |
flagging_mode="never",
|
85 |
).launch()
|