Lambang commited on
Commit
23cf5b4
·
1 Parent(s): b0aaa11
main.py CHANGED
@@ -102,11 +102,12 @@ async def upload_file(picture: UploadFile):
102
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
103
  file_path = os.path.join(UPLOAD_FOLDER, (picture.filename))
104
 
105
- cv2.imwrite("./static/test_upload.jpg", file_path)
106
 
107
  with open(file_path, 'wb') as f:
108
  f.write(picture.file.read())
109
  try:
 
110
  processed_img = preprocessing(cv2.imread(file_path))
111
  except Exception as e:
112
  os.remove(file_path)
@@ -125,7 +126,8 @@ async def upload_file(picture: UploadFile):
125
  # bentuk, persentase = data_train_pred.prediction(selected_model)
126
  # return {'urls': urls, 'bentuk_wajah':bentuk[0], 'persen':persentase}
127
 
128
- # if __name__ == '__main__':
129
- # import uvicorn
130
- # print(f' * Running on {public_url}')
131
- # uvicorn.run(app, host="0.0.0.0", port=8080)
 
 
102
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
103
  file_path = os.path.join(UPLOAD_FOLDER, (picture.filename))
104
 
105
+
106
 
107
  with open(file_path, 'wb') as f:
108
  f.write(picture.file.read())
109
  try:
110
+ cv2.imwrite("./static/test_upload.jpg", cv2.imread(file_path))
111
  processed_img = preprocessing(cv2.imread(file_path))
112
  except Exception as e:
113
  os.remove(file_path)
 
126
  # bentuk, persentase = data_train_pred.prediction(selected_model)
127
  # return {'urls': urls, 'bentuk_wajah':bentuk[0], 'persen':persentase}
128
 
129
+ if __name__ == '__main__':
130
+ import uvicorn
131
+ public_url = ngrok.connect(8080).public_url
132
+ print(f' * Running on {public_url}')
133
+ uvicorn.run(app, host="0.0.0.0", port=8080)
static/result_upload0.jpg ADDED
static/result_upload1.jpg ADDED
static/result_upload2.jpg ADDED
static/temporary/0_36696.jpg ADDED
static/temporary/1_86769.jpg ADDED
static/temporary/2_55170.jpg ADDED
static/temporary/temp DELETED
File without changes
static/test_upload.jpg ADDED
upload/995f2af095b0095f8a99d71f1e64571b.jpg ADDED