Exemplo n.º 1
0
 def detect_skin_disease_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     type="access_key",
                                     endpoint="openplatform.aliyuncs.com",
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product="imageprocess", region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type="access_key",
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     RPCUtilClient.convert(runtime, oss_runtime)
     detect_skin_diseasereq = imageprocess_20200320_models.DetectSkinDiseaseRequest(
     )
     RPCUtilClient.convert(request, detect_skin_diseasereq)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     oss_config.access_key_id = auth_response.access_key_id
     oss_config.endpoint = RPCUtilClient.get_endpoint(
         auth_response.endpoint, auth_response.use_accelerate,
         self._endpoint_type)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.url_object,
         content_type="")
     oss_header = oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status="201")
     upload_request = oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_client.post_object(upload_request, oss_runtime)
     detect_skin_diseasereq.url = "http://" + str(
         auth_response.bucket) + "." + str(
             auth_response.endpoint) + "/" + str(
                 auth_response.object_key) + ""
     detect_skin_disease_resp = self.detect_skin_disease(
         detect_skin_diseasereq, runtime)
     return detect_skin_disease_resp
Exemplo n.º 2
0
 def recognize_vehicle_parts_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     type='access_key',
                                     endpoint='openplatform.aliyuncs.com',
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product='objectdet', region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type='access_key',
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     OpenApiUtilClient.convert(runtime, oss_runtime)
     recognize_vehicle_parts_req = objectdet_20191230_models.RecognizeVehiclePartsRequest(
     )
     OpenApiUtilClient.convert(request, recognize_vehicle_parts_req)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     oss_config.access_key_id = auth_response.access_key_id
     oss_config.endpoint = OpenApiUtilClient.get_endpoint(
         auth_response.endpoint, auth_response.use_accelerate,
         self._endpoint_type)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.image_urlobject,
         content_type='')
     oss_header = oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status='201')
     upload_request = oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_client.post_object(upload_request, oss_runtime)
     recognize_vehicle_parts_req.image_url = 'http://%s.%s/%s' % (
         TeaConverter.to_unicode(auth_response.bucket),
         TeaConverter.to_unicode(auth_response.endpoint),
         TeaConverter.to_unicode(auth_response.object_key))
     recognize_vehicle_parts_resp = self.recognize_vehicle_parts_with_options(
         recognize_vehicle_parts_req, runtime)
     return recognize_vehicle_parts_resp
Exemplo n.º 3
0
    def segment_video_body_advance(self, request, runtime):
        # Step 0: init client
        access_key_id = self._credential.get_access_key_id()
        access_key_secret = self._credential.get_access_key_secret()
        auth_config = _rpc_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret,
            type="access_key",
            endpoint="openplatform.aliyuncs.com",
            protocol=self._protocol,
            region_id=self._region_id
        )
        auth_client = OpenPlatformClient(auth_config)
        auth_request = open_platform_models.AuthorizeFileUploadRequest(
            product="videoseg",
            region_id=self._region_id
        )
        auth_response = auth_client.authorize_file_upload_with_options(auth_request, runtime)
        # Step 1: request OSS api to upload file
        oss_config = _oss_models.Config(
            access_key_id=auth_response.access_key_id,
            access_key_secret=access_key_secret,
            type="access_key",
            endpoint=RPCUtilClient.get_endpoint(auth_response.endpoint, auth_response.use_accelerate, self._endpoint_type),
            protocol=self._protocol,
            region_id=self._region_id
        )
        oss_client = OSSClient(oss_config)
        file_obj = file_form_models.FileField(
            filename=auth_response.object_key,
            content=request.video_url_object,
            content_type=""
        )
        oss_header = _oss_models.PostObjectRequestHeader(
            access_key_id=auth_response.access_key_id,
            policy=auth_response.encoded_policy,
            signature=auth_response.signature,
            key=auth_response.object_key,
            file=file_obj,
            success_action_status="201"
        )
        upload_request = _oss_models.PostObjectRequest(
            bucket_name=auth_response.bucket,
            header=oss_header
        )
        oss_runtime = ossutil_models.RuntimeOptions(

        )
        RPCUtilClient.convert(runtime, oss_runtime)
        oss_client.post_object(upload_request, oss_runtime)
        # Step 2: request final api
        segment_video_bodyreq = videoseg_20200320_models.SegmentVideoBodyRequest(

        )
        RPCUtilClient.convert(request, segment_video_bodyreq)
        segment_video_bodyreq.video_url = "http://" + str(auth_response.bucket) + "." + str(auth_response.endpoint) + "/" + str(auth_response.object_key) + ""
        segment_video_body_resp = self.segment_video_body(segment_video_bodyreq, runtime)
        return segment_video_body_resp
Exemplo n.º 4
0
 def image_blind_pic_watermark_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = _rpc_models.Config(access_key_id=access_key_id,
                                      access_key_secret=access_key_secret,
                                      type="access_key",
                                      endpoint="openplatform.aliyuncs.com",
                                      protocol=self._protocol,
                                      region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product="imageenhan", region_id=self._region_id)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     # Step 1: request OSS api to upload file
     oss_config = _oss_models.Config(
         access_key_id=auth_response.access_key_id,
         access_key_secret=access_key_secret,
         type="access_key",
         endpoint=RPCUtilClient.get_endpoint(auth_response.endpoint,
                                             auth_response.use_accelerate,
                                             self._endpoint_type),
         protocol=self._protocol,
         region_id=self._region_id)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.origin_image_urlobject,
         content_type="")
     oss_header = _oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status="201")
     upload_request = _oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_runtime = ossutil_models.RuntimeOptions()
     RPCUtilClient.convert(runtime, oss_runtime)
     oss_client.post_object(upload_request, oss_runtime)
     # Step 2: request final api
     image_blind_pic_watermarkreq = imageenhan_20190930_models.ImageBlindPicWatermarkRequest(
     )
     RPCUtilClient.convert(request, image_blind_pic_watermarkreq)
     image_blind_pic_watermarkreq.origin_image_url = "http://" + str(
         auth_response.bucket) + "." + str(
             auth_response.endpoint) + "/" + str(
                 auth_response.object_key) + ""
     image_blind_pic_watermark_resp = self.image_blind_pic_watermark(
         image_blind_pic_watermarkreq, runtime)
     return image_blind_pic_watermark_resp
Exemplo n.º 5
0
 def detect_face_attributes_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     security_token = self._credential.get_security_token()
     credential_type = self._credential.get_type()
     open_platform_endpoint = self._open_platform_endpoint
     if UtilClient.is_unset(open_platform_endpoint):
         open_platform_endpoint = 'openplatform.aliyuncs.com'
     if UtilClient.is_unset(credential_type):
         credential_type = 'access_key'
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     security_token=security_token,
                                     type=credential_type,
                                     endpoint=open_platform_endpoint,
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product='Cloudauth', region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type='access_key',
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     OpenApiUtilClient.convert(runtime, oss_runtime)
     detect_face_attributes_req = cloudauth_20201112_models.DetectFaceAttributesRequest(
     )
     OpenApiUtilClient.convert(request, detect_face_attributes_req)
     if not UtilClient.is_unset(request.image_file_object):
         auth_response = auth_client.authorize_file_upload_with_options(
             auth_request, runtime)
         oss_config.access_key_id = auth_response.access_key_id
         oss_config.endpoint = OpenApiUtilClient.get_endpoint(
             auth_response.endpoint, auth_response.use_accelerate,
             self._endpoint_type)
         oss_client = OSSClient(oss_config)
         file_obj = file_form_models.FileField(
             filename=auth_response.object_key,
             content=request.image_file_object,
             content_type='')
         oss_header = oss_models.PostObjectRequestHeader(
             access_key_id=auth_response.access_key_id,
             policy=auth_response.encoded_policy,
             signature=auth_response.signature,
             key=auth_response.object_key,
             file=file_obj,
             success_action_status='201')
         upload_request = oss_models.PostObjectRequest(
             bucket_name=auth_response.bucket, header=oss_header)
         oss_client.post_object(upload_request, oss_runtime)
         detect_face_attributes_req.image_file = 'http://%s.%s/%s' % (
             TeaConverter.to_unicode(auth_response.bucket),
             TeaConverter.to_unicode(auth_response.endpoint),
             TeaConverter.to_unicode(auth_response.object_key))
     detect_face_attributes_resp = self.detect_face_attributes_with_options(
         detect_face_attributes_req, runtime)
     return detect_face_attributes_resp