| 12345678910111213141516171819202122232425262728293031 |
- from models import *
- import datetime
- from services.SegmentService import SegmentService
- from services.deal_cutout import DealCutout
- @app.get("/")
- async def index():
- """入口文件"""
- return {
- "message": "请求成功",
- "data": f"Hello, World!",
- }
- @app.post("/api/check_select_images", description="检查目录或文件")
- async def checkSelect(params: CheckSelectImages):
- service = SegmentService()
- file_path = params.path
- path_type = params.path_type
- image_list = params.image_list
- deal_cutout_mode = DealCutout()
- if path_type == 0:
- need_cutout_images = service.initImages(image_list=image_list)
- else:
- need_cutout_images = service.check_need_cutout_images(file_path)
- if len([x for x in need_cutout_images if x["need_cutout"]]) == 0:
- raise UnicornException("您所选文件夹下没有jpg图片,或对应图片已扣图")
- deal_cutout_mode.need_cutout_images = need_cutout_images
- deal_cutout_mode.start()
- # print("list_result", need_cutout_images)
- return success(need_cutout_images)
|