| Algorithm 4: Diagnosis_Request_Service |
|
Input: skin_image, service_type Output: class of skin disease |
| 1 Function: skin_diagnosis (skin_image, service_type) 2 Init: ip ← grpc server ip address, crt ← server certificate, url ← cloud service URL, 3 service_id ← nearby service ID, user_name ← given device name 4 Try 5 If service_type = = mobile_local_service Then //request from the local service 6 P[p0, … ,pC] ← mobile_local_service.get_diagnosis (skin_image) 7 Else If service_type = = mobile_remote_service Then //Create connection with the nearby device 8 connection ← request_connection(user_name) //Send a request to the diagnosis service 9 P[p0, … ,pC] ← connection.get_diagnosis (skin_image) 10 Else If service_type = = grpc_service Then //Create a secure channel with the diagnosis service 11 channel ← create_secure_channel (ip, crt) 12 P[p0, … ,pC] ← channel.get_diagnosis (skin_image) 13 Else If service_type = = containerized_grpc_service Then //Create a secure channel with the cloud 14 channel ← create_secure_channel (url) 15 P[p0, … ,pC] ← channel.get_diagnosis (skin_image) 16 End If //Find the largest probability value 17 probability ← p0 18 prediction_class ← 0 19 For c in C 20 If P[c] > probability Then 21 probability ← P[c] 22 prediction_class ← c 23 End If 24 End For //Find corresponding labels 25 prediction_label ← get_prediction_label(prediction_class) 26 Return prediction_label 27 Catch exception 28 Return error_message 29 End Try |