Update app.py
Browse files
app.py
CHANGED
|
@@ -79,10 +79,16 @@ def segment_image(image_path, client):
|
|
| 79 |
|
| 80 |
# Roboflow API 호출
|
| 81 |
results = client.infer(encoded_image, model_id="closet/1")
|
| 82 |
-
results = json.loads(results)
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
points = prediction['points']
|
| 87 |
pts = np.array([[p['x'], p['y']] for p in points], np.int32)
|
| 88 |
scale_x = image.shape[1] / results['image']['width']
|
|
|
|
| 79 |
|
| 80 |
# Roboflow API 호출
|
| 81 |
results = client.infer(encoded_image, model_id="closet/1")
|
|
|
|
| 82 |
|
| 83 |
+
# 결과가 이미 딕셔너리인 경우 JSON 파싱 단계 제거
|
| 84 |
+
if isinstance(results, dict):
|
| 85 |
+
predictions = results.get('predictions', [])
|
| 86 |
+
else:
|
| 87 |
+
# 문자열인 경우에만 JSON 파싱
|
| 88 |
+
predictions = json.loads(results).get('predictions', [])
|
| 89 |
+
|
| 90 |
+
if predictions:
|
| 91 |
+
for prediction in predictions:
|
| 92 |
points = prediction['points']
|
| 93 |
pts = np.array([[p['x'], p['y']] for p in points], np.int32)
|
| 94 |
scale_x = image.shape[1] / results['image']['width']
|