wai572 commited on
Commit
001e747
·
1 Parent(s): f9adc21

file convert nparray

Browse files
Files changed (1) hide show
  1. main.py +4 -3
main.py CHANGED
@@ -126,9 +126,10 @@ async def analyze_image(image_paths: list[UploadFile]):
126
  # bytearray(f.read()), dtype=np.uint8
127
  # )
128
  # NumPy配列(メモリ上のデータ)から画像をデコード
129
- file = await image_path.file.read()
130
- print(file)
131
- image = cv2.imdecode(file, cv2.IMREAD_COLOR)
 
132
  # image = image_path.file
133
 
134
  if image is None:
 
126
  # bytearray(f.read()), dtype=np.uint8
127
  # )
128
  # NumPy配列(メモリ上のデータ)から画像をデコード
129
+ file_bytes = await image_path.read()
130
+ print("file", file_bytes)
131
+ file_array = np.asarray(bytearray(file_bytes), dtype=np.uint8)
132
+ image = cv2.imdecode(file_array, cv2.IMREAD_COLOR)
133
  # image = image_path.file
134
 
135
  if image is None: