@@ -128,7 +128,6 @@ def upload_minifig_image(file: UploadFile = File(...)) -> JSONResponse:
128128 Returns:
129129 JSONResponse: 結果メッセージとステータスコード
130130 """
131-
132131 # 画像のファイル名の取得
133132 file_name = file .filename
134133
@@ -164,31 +163,37 @@ def upload_minifig_image(file: UploadFile = File(...)) -> JSONResponse:
164163 if detection_result ["direction" ] == "front" :
165164 # frontは既存がfront以外なら即更新、frontなら高信頼度で更新
166165 if (best_minifig_result ["best_direction" ] != "front" or
167- detection_result ["confidence" ] > best_minifig_result ["best_confidence" ]):
166+ detection_result ["confidence" ] >
167+ best_minifig_result ["best_confidence" ]):
168168 # それぞれの値を更新
169169 best_minifig_result ["best_image_path" ] = file_path
170- best_minifig_result ["best_confidence" ] = detection_result ["confidence" ]
171- best_minifig_result ["best_direction" ] = detection_result ["direction" ]
170+ best_minifig_result ["best_confidence" ] = (
171+ detection_result ["confidence" ])
172+ best_minifig_result ["best_direction" ] = (
173+ detection_result ["direction" ])
172174
173175 # 既存の最良画像がfrontでなく、検出結果の信頼度が高い場合
174176 elif (best_minifig_result ["best_direction" ] != "front" and
175- detection_result ["confidence" ] > best_minifig_result ["best_confidence" ]):
177+ detection_result ["confidence" ] >
178+ best_minifig_result ["best_confidence" ]):
176179 # それぞれの値を更新
177180 best_minifig_result ["best_image_path" ] = file_path
178- best_minifig_result ["best_confidence" ] = detection_result ["confidence" ]
179- best_minifig_result ["best_direction" ] = detection_result ["direction" ]
181+ best_minifig_result ["best_confidence" ] = (
182+ detection_result ["confidence" ])
183+ best_minifig_result ["best_direction" ] = (
184+ detection_result ["direction" ])
180185
181186 # 4枚未満の場合
182187 if best_minifig_result ["image_count" ] < 4 :
183188 return JSONResponse (
184189 content = {
185- "message" : f"Image { best_minifig_result ['image_count' ]} processed successfully" ,
190+ "message" : (f"Image { best_minifig_result ['image_count' ]} "
191+ "processed successfully" ),
186192 "detection_result" : detection_result ,
187193 "images_received" : best_minifig_result ["image_count" ],
188- "remaining" : 4 - best_minifig_result ["image_count" ]
189- },
190- status_code = status .HTTP_200_OK
191- )
194+ "remaining" : 4 -
195+ best_minifig_result ["image_count" ]},
196+ status_code = status .HTTP_200_OK )
192197
193198 # アップロード対象画像を決定
194199 if best_minifig_result ["best_image_path" ]:
0 commit comments