class_docstr: Basic MONAILabel Client to invoke infer/train APIs over http/https
class_docstr_tok: ["Basic","MONAILabel","Client","to","invoke","infer\/train","APIs","over","http\/https"]
docstr: Run Infer
  
  :param model: Name of Model
  :param image_id: Image Id
  :param params: Additional configs/json params as part of Infer request
  :param label_in: File path for label mask which is needed to run Inference (e.g. In case of Scribbles)
  :param file: File path for Image (use raw image instead of image_id)
  :param session_id: Session ID (use existing session id instead of image_id)
  :return: response_file (label mask), response_body (json result/output params)
docstr_tok: ["Run","Infer",":","param","model",":","Name","of","Model",":","param","image_id",":","Image","Id",":","param","params",":","Additional","configs\/json","params","as","part","of","Infer","request",":","param","label_in",":","File","path","for","label","mask","which","is","needed","to","run","Inference","(","e.g",".","In","case","of","Scribbles",")",":","param","file",":","File","path","for","Image","(","use","raw","image","instead","of","image_id",")",":","param","session_id",":","Session","ID","(","use","existing","session","id","instead","of","image_id",")",":","return",":","response_file","(","label","mask",")",",","response_body","(","json","result\/output","params",")"]
code: def infer(
      self,
      model,
      image_id,
      params,
      label_in=None,
      file=None,
      session_id=None,
  ):
      """
      Run Infer
  
      :param model: Name of Model
      :param image_id: Image Id
      :param params: Additional configs/json params as part of Infer request
      :param label_in: File path for label mask which is needed to run Inference (e.g. In case of Scribbles)
      :param file: File path for Image (use raw image instead of image_id)
      :param session_id: Session ID (use existing session id instead of image_id)
      :return: response_file (label mask), response_body (json result/output params)
      """
      selector = "/infer/{}?image={}".format(
          MONAILabelUtils.urllib_quote_plus(model),
          MONAILabelUtils.urllib_quote_plus(image_id),
      )
      if session_id:
          selector += f"&session_id={MONAILabelUtils.urllib_quote_plus(session_id)}"
  
      params = self._update_client_id(params)
      fields = {"params": json.dumps(params) if params else "{}"}
      files = {"label": label_in} if label_in else {}
      files.update({"file": file} if file and not session_id else {})
  
      status, form, files, _ = MONAILabelUtils.http_multipart(
          "POST",
          self._server_url,
          selector,
          fields,
          files,
          headers=self._headers,
      )
      if status != 200:
          raise MONAILabelClientException(
              MONAILabelError.SERVER_ERROR,
              f"Status: {status}; Response: {bytes_to_str(form)}",
          )
  
      form = json.loads(form) if isinstance(form, str) else form
      params = form.get("params") if files else form
      params = json.loads(params) if isinstance(params, str) else params
  
      image_out = MONAILabelUtils.save_result(files, self._tmpdir)
      return image_out, params
  
imports: import cgi
  import http.client
  import json
  import logging
  import mimetypes
  import os
  import re
  import ssl
  import tempfile
  from pathlib import Path
  from urllib.parse import quote_plus, unquote, urlencode, urlparse
  import requests
label_desc: Use image node_id 18 for calling the MONAILabelClient obj's underlying member method code with example usage: obj.infer(model, image_id, params, label_in, file, session_id) and returns: image_out,  params