jibsn commited on
Commit
cd6eed7
·
verified ·
1 Parent(s): ec3a96c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -20
app.py CHANGED
@@ -4,7 +4,6 @@ import gradio as gr
4
  import os
5
 
6
  import sys
7
- # sys.path.append('/app')
8
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
9
 
10
  from ONNX0630 import main as predict_smiles
@@ -16,28 +15,11 @@ import logging
16
  # 设置日志
17
  logging.basicConfig(level=logging.INFO)
18
  logger = logging.getLogger(__name__)
19
-
20
- # Gradio interface
21
- # def gradio_predict(image):
22
- # try:
23
- # # Save the uploaded image
24
- # temp_path = "temp_image.png"
25
- # image.save(temp_path)
26
-
27
- # # Call the model function
28
- # smiles = predict_smiles(temp_path)
29
-
30
- # # Clean up
31
- # os.remove(temp_path)
32
-
33
- # return smiles
34
- # except Exception as e:
35
- # return f"Error: {str(e)}"
36
-
37
  def gradio_predict(image):
38
  try:
39
  # 使用临时文件目录保存图片
40
- with tempfile.NamedTemporaryFile(suffix=".png", dir="/home/user/app", delete=False) as temp_file:
41
  temp_path = temp_file.name
42
  logger.info(f"temp_path: {temp_path}")
43
  image.save(temp_path)
 
4
  import os
5
 
6
  import sys
 
7
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
8
 
9
  from ONNX0630 import main as predict_smiles
 
15
  # 设置日志
16
  logging.basicConfig(level=logging.INFO)
17
  logger = logging.getLogger(__name__)
18
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def gradio_predict(image):
20
  try:
21
  # 使用临时文件目录保存图片
22
+ with tempfile.NamedTemporaryFile(suffix=".png", dir="/temp", delete=False) as temp_file:
23
  temp_path = temp_file.name
24
  logger.info(f"temp_path: {temp_path}")
25
  image.save(temp_path)