syurein commited on
Commit
d63a0d3
·
1 Parent(s): b3d6d35

二つ分にした

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -992,11 +992,8 @@ async def classify_image_llm(file: UploadFile = File(...)):
992
  return {"danger":danger_level}
993
 
994
 
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
  value: str = Form(...),
@@ -1036,6 +1033,32 @@ async def create_mask_sum2(image: UploadFile = File(...),
1036
  return FileResponse(output_path)
1037
 
1038
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1039
  #三浦と相談
1040
 
1041
  @app.post("/create-mask-and-inpaint-sum-llm-auto")
 
992
  return {"danger":danger_level}
993
 
994
 
 
 
 
995
  @app.post("/analyze")
996
+ async def create_mask_sum3(image: UploadFile = File(...),
997
  scene: str = Form(...),
998
  mode: str = Form(...),
999
  value: str = Form(...),
 
1033
  return FileResponse(output_path)
1034
 
1035
 
1036
+ @app.post("/create-mask-and-inpaint-sum-llm-simple")
1037
+ async def create_mask_sum2(image: UploadFile = File(...), risk_level: int = Form(...),
1038
+ x1: float = Form(...),
1039
+ y1: float = Form(...),
1040
+ x2: float = Form(...),
1041
+ y2: float = Form(...),):
1042
+ default_x = 0.001
1043
+ default_y = 0.001
1044
+
1045
+
1046
+ point1 = [default_x if math.isnan(x1) else x1, default_y if math.isnan(y1) else y1]
1047
+
1048
+ point2 = [default_x if math.isnan(x2) else x2, default_y if math.isnan(y2) else y2]
1049
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
1050
+ # 一意な識別子を生成
1051
+ unique_id = uuid.uuid4().hex
1052
+ input_path = save_image(image.file, f"./input_{timestamp}_{unique_id}.jpg")
1053
+ mask_path = llm_to_process_image_simple(risk_level, input_path, point1, point2,thresholds=thresholds)
1054
+ output_path = f"./output_simple_lama_{timestamp}_{unique_id}.jpg"
1055
+ print('point1,point2',point1,point2)#消去したくない範囲のこと
1056
+ # OpenCVでインペイント
1057
+ inpaint_image_with_mask1(input_path, mask_path, output_path)
1058
+
1059
+ return FileResponse(output_path)
1060
+
1061
+
1062
  #三浦と相談
1063
 
1064
  @app.post("/create-mask-and-inpaint-sum-llm-auto")