Scezui commited on
Commit
5f1b803
·
1 Parent(s): 1c95f76

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -68,8 +68,8 @@ def upload_file():
68
 
69
  def make_prediction(image_path):
70
  try:
71
- temp = pathlib.PosixPath # Save the original state
72
- pathlib.PosixPath = pathlib.WindowsPath # Change to WindowsPath temporarily
73
 
74
  model_path = Path(r'model\export')
75
 
@@ -88,8 +88,8 @@ def make_prediction(image_path):
88
 
89
  except Exception as e:
90
  return {"error": str(e)}
91
- finally:
92
- pathlib.PosixPath = temp
93
 
94
 
95
  @app.route('/rename/<old_name>', methods=['GET', 'POST'])
@@ -102,7 +102,9 @@ def rename_file(old_name):
102
  shutil.move(file_path, new_file_path)
103
 
104
  # Call make_prediction automatically
105
- prediction_result = make_prediction(new_file_path)
 
 
106
 
107
  return render_template('extractor.html', uploaded_file=new_name, old_name=old_name, prediction_result=prediction_result)
108
  else:
 
68
 
69
  def make_prediction(image_path):
70
  try:
71
+ # temp = pathlib.PosixPath # Save the original state
72
+ # pathlib.PosixPath = pathlib.WindowsPath # Change to WindowsPath temporarily
73
 
74
  model_path = Path(r'model\export')
75
 
 
88
 
89
  except Exception as e:
90
  return {"error": str(e)}
91
+ # finally:
92
+ # pathlib.PosixPath = temp
93
 
94
 
95
  @app.route('/rename/<old_name>', methods=['GET', 'POST'])
 
102
  shutil.move(file_path, new_file_path)
103
 
104
  # Call make_prediction automatically
105
+ prediction_results = make_prediction(new_file_path)
106
+ prediction_result = str(prediction_results)
107
+ print(f"The prediction is: ", prediction_result)
108
 
109
  return render_template('extractor.html', uploaded_file=new_name, old_name=old_name, prediction_result=prediction_result)
110
  else: