data.py 859 B

12345678910111213141516171819202122232425262728
  1. import settings
  2. from module.data_mode.data_metaclass import DataBaseModel
  3. from PIL import Image
  4. from io import BytesIO
  5. class DataModeAutoDealPics(DataBaseModel):
  6. def __init__(self):
  7. super().__init__()
  8. def check_is_right_foot_by_api(self, image):
  9. image = image.convert('RGB')
  10. re_x = int(640)
  11. re_y = int(image.height * re_x / image.width)
  12. image = image.resize((re_x, re_y))
  13. e = "JPEG"
  14. img = BytesIO()
  15. image.save(img, format=e) # format: PNG or JPEG
  16. img.seek(0) # rewind to the start
  17. image_url = self.get_online_data.upload_image_by_io(image_io=img)
  18. if settings.IS_TEST:
  19. print("识别左右脚,{}".format(image_url))
  20. # 识别左右脚
  21. r_data = self.get_online_data.yolo_shoes_category(image_url=image_url)
  22. return r_data