Spaces:
Runtime error
Runtime error
syurein commited on
Commit ·
6480738
1
Parent(s): 6c31327
危険度判定の正確な実装
Browse files
app.py
CHANGED
|
@@ -984,7 +984,13 @@ async def mosaic_face(file: UploadFile = File(...)):
|
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 988 |
|
| 989 |
|
| 990 |
|
|
@@ -1113,9 +1119,11 @@ async def analyze(
|
|
| 1113 |
unique_id = uuid.uuid4().hex
|
| 1114 |
input_path = save_image(file.file, f"input_{timestamp}_{unique_id}.jpg")
|
| 1115 |
if mode== 'auto':
|
| 1116 |
-
mask_path,response =await llm_to_process_image_simple_auto(risk_level, input_path, point1, point2,thresholds=thresholds)
|
| 1117 |
-
|
|
|
|
| 1118 |
mask_path = llm_to_process_image_simple(risk_level, input_path, point1, point2, thresholds=thresholds)
|
|
|
|
| 1119 |
output_path = f"./output_simple_lama_{timestamp}_{unique_id}.jpg"
|
| 1120 |
print(f'point1,point2: {point1},{point2}') # 消去したくない範囲
|
| 1121 |
|
|
@@ -1125,7 +1133,7 @@ async def analyze(
|
|
| 1125 |
return FileResponse(
|
| 1126 |
output_path,
|
| 1127 |
media_type="image/jpeg",
|
| 1128 |
-
headers={"x-danger":
|
| 1129 |
)
|
| 1130 |
|
| 1131 |
except Exception as e:
|
|
|
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
+
async def classify_image_llm2(file: UploadFile = File(...)):
|
| 988 |
+
image_path = "./temp_image.jpg"
|
| 989 |
+
# アップロードされた画像を保存
|
| 990 |
+
with open(image_path, "wb") as buffer:
|
| 991 |
+
buffer.write(await file.read())
|
| 992 |
+
danger_level = ObjectDetector().detect_danger_level(image_path)
|
| 993 |
+
return {"danger":danger_level}
|
| 994 |
|
| 995 |
|
| 996 |
|
|
|
|
| 1119 |
unique_id = uuid.uuid4().hex
|
| 1120 |
input_path = save_image(file.file, f"input_{timestamp}_{unique_id}.jpg")
|
| 1121 |
if mode== 'auto':
|
| 1122 |
+
mask_path,response =await llm_to_process_image_simple_auto(risk_level, input_path, point1, point2,thresholds=thresholds,scene=scene)
|
| 1123 |
+
response = response['risk_level'] # レスポンスから必要な情報を抽出
|
| 1124 |
+
elif mode == 'fast':
|
| 1125 |
mask_path = llm_to_process_image_simple(risk_level, input_path, point1, point2, thresholds=thresholds)
|
| 1126 |
+
response=await classify_image_llm2(file)
|
| 1127 |
output_path = f"./output_simple_lama_{timestamp}_{unique_id}.jpg"
|
| 1128 |
print(f'point1,point2: {point1},{point2}') # 消去したくない範囲
|
| 1129 |
|
|
|
|
| 1133 |
return FileResponse(
|
| 1134 |
output_path,
|
| 1135 |
media_type="image/jpeg",
|
| 1136 |
+
headers={"x-danger": str(response)} # 実際の処理では危険度を適切に設定
|
| 1137 |
)
|
| 1138 |
|
| 1139 |
except Exception as e:
|