MissingBreath commited on
Commit
74dc566
·
verified ·
1 Parent(s): 0556fc9

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +11 -4
api.py CHANGED
@@ -112,10 +112,17 @@ async def ipredict(image: UploadFile = File(...)):
112
  @app.post("/vpredict")
113
  async def vpredict(image: UploadFile = File(...)):
114
  if image is not None:
115
- img = Image.open(io.BytesIO(await image.read()))
116
- # img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
117
- img = cv2.imdecode(np.array(img), cv2.IMREAD_COLOR)
118
- print("IAM HERE **********************************************************************************")
 
 
 
 
 
 
 
119
  # img = img.resize((128, 128))
120
  # img_array = np.array(img) / 255.0
121
  # Get the prediction
 
112
  @app.post("/vpredict")
113
  async def vpredict(image: UploadFile = File(...)):
114
  if image is not None:
115
+ # img = Image.open(io.BytesIO(await image.read()))
116
+ # # img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
117
+ # img = cv2.imdecode(np.array(img), cv2.IMREAD_COLOR)
118
+ # print("IAM HERE **********************************************************************************")
119
+ image_bytes = await image.read()
120
+
121
+ # Convert bytes to a NumPy uint8 array
122
+ nparr = np.frombuffer(image_bytes, np.uint8)
123
+
124
+ # Decode into OpenCV image (BGR format)
125
+ img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
126
  # img = img.resize((128, 128))
127
  # img_array = np.array(img) / 255.0
128
  # Get the prediction