lsy1205 commited on
Commit
b1a6fde
·
1 Parent(s): 71770d2

modify input

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -10,11 +10,11 @@ model.load_state_dict(torch.load("./Attn_conv.pth", weights_only=True,map_locati
10
  model.eval()
11
 
12
  # 推理函数
13
- def predict(file):
14
  # 读取上传的 JSON 文件
15
  try:
16
- with open(file.name, "r") as f:
17
- data = json.load(f)
18
 
19
  channels = ["AccelX", "AccelY", "AccelZ", "GyroX", "GyroY", "GyroZ"]
20
 
@@ -62,7 +62,7 @@ def predict(file):
62
  # 定义 Gradio 界面
63
  iface = gr.Interface(
64
  fn=predict,
65
- inputs=gr.File(label="json file"),
66
  outputs=gr.Textbox(label="Prediction Result"),
67
  title="Burnsync classifier",
68
  description="Upload a JSON file with 6-channel IMU time series data to predict the action class."
 
10
  model.eval()
11
 
12
  # 推理函数
13
+ def predict(data):
14
  # 读取上传的 JSON 文件
15
  try:
16
+ # with open(file.name, "r") as f:
17
+ # data = json.load(f)
18
 
19
  channels = ["AccelX", "AccelY", "AccelZ", "GyroX", "GyroY", "GyroZ"]
20
 
 
62
  # 定义 Gradio 界面
63
  iface = gr.Interface(
64
  fn=predict,
65
+ inputs=gr.JSON(label="json file"),
66
  outputs=gr.Textbox(label="Prediction Result"),
67
  title="Burnsync classifier",
68
  description="Upload a JSON file with 6-channel IMU time series data to predict the action class."