tumuyan2 commited on
Commit
c0d8acd
·
1 Parent(s): f64dbb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -244,10 +244,14 @@ def start_process(input1, input2, shape0_str, shape1_str, input_suffix=".pth"):
244
  except Exception as e:
245
  log += f"执行命令: {command} 失败,错误信息: {str(e)}\n"
246
 
247
- # 查文件是否存在
248
- bin_file = os.path.join(output_folder, input2 + ".ncnn.bin")
249
- param_file = os.path.join(output_folder, input2 + ".ncnn.param")
250
- if os.path.exists(bin_file) and os.path.exists(param_file):
 
 
 
 
251
  import zipfile
252
  # 压缩包名称
253
  zip_file_name = os.path.join(output_folder, f"models-{input2}.zip")
@@ -265,7 +269,11 @@ def start_process(input1, input2, shape0_str, shape1_str, input_suffix=".pth"):
265
  log += f"已创建压缩包: {zip_file_name}\n"
266
  print_log(task_id, input2, "创建压缩包"+zip_file_name, "完成")
267
  yield [], log
268
-
 
 
 
 
269
  output_files = [os.path.join(output_folder, f) for f in os.listdir(output_folder) if os.path.isfile(os.path.join(output_folder, f))]
270
  log += f"任务完成\n"
271
  print_log(task_id, input2, "执行命令", "完成")
 
244
  except Exception as e:
245
  log += f"执行命令: {command} 失败,错误信息: {str(e)}\n"
246
 
247
+ # 查找 output_folder 目录下以 .ncnn.bin 和 .ncnn.param 结尾的文件
248
+ bin_files = [f for f in os.listdir(output_folder) if f.endswith('.ncnn.bin')]
249
+ param_files = [f for f in os.listdir(output_folder) if f.endswith('.ncnn.param')]
250
+
251
+
252
+ if bin_files and param_files:
253
+ param_file = os.path.join(output_folder, param_files[0])
254
+ bin_file = os.path.join(output_folder, bin_files[0])
255
  import zipfile
256
  # 压缩包名称
257
  zip_file_name = os.path.join(output_folder, f"models-{input2}.zip")
 
269
  log += f"已创建压缩包: {zip_file_name}\n"
270
  print_log(task_id, input2, "创建压缩包"+zip_file_name, "完成")
271
  yield [], log
272
+ else:
273
+ log += f"未找到 ncnn 文件\n"
274
+ print_log(task_id, input2, "查找 ncnn 文件", "失败")
275
+ yield [], log
276
+
277
  output_files = [os.path.join(output_folder, f) for f in os.listdir(output_folder) if os.path.isfile(os.path.join(output_folder, f))]
278
  log += f"任务完成\n"
279
  print_log(task_id, input2, "执行命令", "完成")