Spaces:
Running
Running
syurein
commited on
Commit
·
d638497
1
Parent(s):
31d2be8
一度テスト
Browse files- aidentify-ui +1 -0
- app.py +25 -10
aidentify-ui
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit 7ea16cac1e8ef83c94e38e6fc3d7587838a3d30e
|
app.py
CHANGED
@@ -995,19 +995,34 @@ async def classify_image_llm(file: UploadFile = File(...)):
|
|
995 |
|
996 |
|
997 |
|
998 |
-
@app.post("/
|
999 |
-
async def create_mask_sum2(image: UploadFile = File(...),
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
default_x = 0.001
|
1005 |
default_y = 0.001
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1006 |
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
point2 = [default_x if math.isnan(x2) else x2, default_y if math.isnan(y2) else y2]
|
1011 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
1012 |
# 一意な識別子を生成
|
1013 |
unique_id = uuid.uuid4().hex
|
|
|
995 |
|
996 |
|
997 |
|
998 |
+
@app.post("/analyze")
|
999 |
+
async def create_mask_sum2(image: UploadFile = File(...),
|
1000 |
+
scene: str = Form(...),
|
1001 |
+
mode: str = Form(...),
|
1002 |
+
risk_level: str = Form(...),
|
1003 |
+
rect: str = Form(...),):
|
1004 |
default_x = 0.001
|
1005 |
default_y = 0.001
|
1006 |
+
risk_level= int(risk_level) if risk_level.isdigit() else 0 # リスクレベルを整数に変換
|
1007 |
+
|
1008 |
+
# rect JSON文字列をパースして座標を取得
|
1009 |
+
try:
|
1010 |
+
# rectが空文字列や "null" の場合を考慮
|
1011 |
+
if rect and rect.strip() and rect.lower() != 'null':
|
1012 |
+
rect_data = json.loads(rect)
|
1013 |
+
x1 = float(rect_data.get('x1', default_x))
|
1014 |
+
y1 = float(rect_data.get('y1', default_y))
|
1015 |
+
x2 = float(rect_data.get('x2', default_x))
|
1016 |
+
y2 = float(rect_data.get('y2', default_y))
|
1017 |
+
else:
|
1018 |
+
# rectが提供されない場合のデフォルト値
|
1019 |
+
x1, y1, x2, y2 = default_x, default_y, default_x, default_y
|
1020 |
+
except (json.JSONDecodeError, TypeError, ValueError):
|
1021 |
+
# JSONパースエラーや型変換エラーの場合のフォールバック
|
1022 |
+
x1, y1, x2, y2 = default_x, default_y, default_x, default_y
|
1023 |
|
1024 |
+
point1 = [x1, y1]
|
1025 |
+
point2 = [x2, y2]
|
|
|
|
|
1026 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
1027 |
# 一意な識別子を生成
|
1028 |
unique_id = uuid.uuid4().hex
|