{
  "id": 223695,
  "title": "how to hand label images",
  "url": "/competitions/ranzcr-clip-catheter-line-classification/discussion/223695",
  "author_name": "hengck23",
  "post_date": "2021-03-05T06:17:20.342000",
  "votes": 13,
  "comment_count": 4,
  "views": 0,
  "content": "<p>i just label difficult cvc cases (endpoint only)</p>\n<p><img src=\"https://i.ibb.co/jb5vy1X/Selection-047.png\" alt=\"\"><br>\n<img src=\"https://i.ibb.co/9YX7Y0d/Selection-046.png\" alt=\"\"><br>\n<img src=\"https://i.ibb.co/VY6QJ6n/Selection-048.png\" alt=\"\"></p>",
  "messages": [
    {
      "id": 1227050,
      "postDate": "2021-03-05T06:17:20.343Z",
      "content": "<p>i just label difficult cvc cases (endpoint only)</p>\n<p><img src=\"https://i.ibb.co/jb5vy1X/Selection-047.png\" alt=\"\"><br>\n<img src=\"https://i.ibb.co/9YX7Y0d/Selection-046.png\" alt=\"\"><br>\n<img src=\"https://i.ibb.co/VY6QJ6n/Selection-048.png\" alt=\"\"></p>",
      "rawMarkdown": "i just label difficult cvc cases (endpoint only)\n\n![](https://i.ibb.co/jb5vy1X/Selection-047.png)\n![](https://i.ibb.co/9YX7Y0d/Selection-046.png)\n![](https://i.ibb.co/VY6QJ6n/Selection-048.png)",
      "votes": 13
    },
    {
      "id": 1227209,
      "postDate": "2021-03-05T09:55:35.497Z",
      "content": "<p>Alternative approach is to use RFCx method:<br>\n-use model to generate high confidence candidates<br>\n-then use hand label to mark as FP and TP</p>",
      "rawMarkdown": "Alternative approach is to use RFCx method:\n-use model to generate high confidence candidates\n-then use hand label to mark as FP and TP",
      "votes": 1
    },
    {
      "id": 1227113,
      "postDate": "2021-03-05T08:09:08.293Z",
      "content": "<p>FYI - see this discussion for requirements for hand labeled / re-annotated train images or external images<br>\n<a href=\"https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644\" target=\"_blank\">https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644</a></p>",
      "rawMarkdown": "FYI - see this discussion for requirements for hand labeled / re-annotated train images or external images\nhttps://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644",
      "votes": 1
    },
    {
      "id": 1227053,
      "postDate": "2021-03-05T06:18:55.453Z",
      "content": "<pre><code>from common import *\nfrom ranzcr import *\n\ndata_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification'\n\ndf_annotation = pd.read_csv(data_dir + '/train_annotations.more.fix.csv')\ndf = pd.read_csv(data_dir + '/train.more.fix.csv')\ndf = df[df.fold!=1]\n\n#-------------------------\nclahe = cv2.createCLAHE(clipLimit=8, tileGridSize=(8, 8))\n#clahe = cv2.createCLAHE(clipLimit=13.5, tileGridSize=(8, 8))\n\n\n# is_a=1  #ground truth\n# dump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/truth'\n# os.makedirs(dump_dir, exist_ok=True)\n# df = df[df.is_annotate==1]\n\nis_a=0\ndump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/try'\nos.makedirs(dump_dir, exist_ok=True)\ndf = df[df.is_annotate==0]\n\n\n#-----------------------------------------\ndf = df.reset_index(drop=True)\nindex = np.arange(len(df))\nfor i in index[:300]:\n    print(i)\n    d = df.iloc[i]\n\n    image = cv2.imread(data_dir+'/train/%s.jpg'%d.StudyInstanceUID, cv2.IMREAD_GRAYSCALE)\n    image = cv2.resize(image, dsize=(768,768), interpolation=cv2.INTER_LINEAR)\n    image = 255-image\n    image = clahe.apply(image)\n\n    is_cvc=0\n    if d[target_col[7]]==1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[7], (5,20), 0.6, 255,1)\n\n    if d[target_col[8]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[8], (5,40), 0.6, 255, 1)\n\n    if d[target_col[9]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[9], (5,60), 0.6, 255, 1)\n    if is_cvc == 0 : continue\n\n    if is_a==1:\n        df_a = df_annotation[df_annotation.StudyInstanceUID==d.StudyInstanceUID]\n        for row in df_a.iterrows():\n            if 'CVC' in row[1].label:\n                point = np.array(eval(row[1].data))*[[768,768]]\n                point = point.astype(np.int32)\n\n                x,y = point[0]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n                x,y = point[-1]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n\n                for x,y in point:\n                    cv2.circle(image,(x,y),1,255,-1,cv2.LINE_AA)\n\n\n    image_show('image', image)\n    cv2.waitKey(1)\n    cv2.imwrite(dump_dir+'/%s.png'%d.StudyInstanceUID,image)\n</code></pre>",
      "rawMarkdown": "```\nfrom common import *\nfrom ranzcr import *\n\ndata_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification'\n\ndf_annotation = pd.read_csv(data_dir + '/train_annotations.more.fix.csv')\ndf = pd.read_csv(data_dir + '/train.more.fix.csv')\ndf = df[df.fold!=1]\n \n#-------------------------\nclahe = cv2.createCLAHE(clipLimit=8, tileGridSize=(8, 8))\n#clahe = cv2.createCLAHE(clipLimit=13.5, tileGridSize=(8, 8))\n \n\n# is_a=1  #ground truth\n# dump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/truth'\n# os.makedirs(dump_dir, exist_ok=True)\n# df = df[df.is_annotate==1]\n \nis_a=0\ndump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/try'\nos.makedirs(dump_dir, exist_ok=True)\ndf = df[df.is_annotate==0]\n\n\n#-----------------------------------------\ndf = df.reset_index(drop=True)\nindex = np.arange(len(df))\nfor i in index[:300]:\n    print(i)\n    d = df.iloc[i]\n\n    image = cv2.imread(data_dir+'/train/%s.jpg'%d.StudyInstanceUID, cv2.IMREAD_GRAYSCALE)\n    image = cv2.resize(image, dsize=(768,768), interpolation=cv2.INTER_LINEAR)\n    image = 255-image\n    image = clahe.apply(image)\n\n    is_cvc=0\n    if d[target_col[7]]==1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[7], (5,20), 0.6, 255,1)\n\n    if d[target_col[8]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[8], (5,40), 0.6, 255, 1)\n\n    if d[target_col[9]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[9], (5,60), 0.6, 255, 1)\n    if is_cvc == 0 : continue\n\n    if is_a==1:\n        df_a = df_annotation[df_annotation.StudyInstanceUID==d.StudyInstanceUID]\n        for row in df_a.iterrows():\n            if 'CVC' in row[1].label:\n                point = np.array(eval(row[1].data))*[[768,768]]\n                point = point.astype(np.int32)\n\n                x,y = point[0]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n                x,y = point[-1]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n\n                for x,y in point:\n                    cv2.circle(image,(x,y),1,255,-1,cv2.LINE_AA)\n\n\n    image_show('image', image)\n    cv2.waitKey(1)\n    cv2.imwrite(dump_dir+'/%s.png'%d.StudyInstanceUID,image)\n\n\n```",
      "votes": 1
    },
    {
      "id": 1234764,
      "postDate": "2021-03-11T15:06:23.870Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1227209,
      "author_name": "hengck23",
      "author_url": "",
      "post_date": "2021-03-05T09:55:35.497000",
      "content": "<p>Alternative approach is to use RFCx method:<br>\n-use model to generate high confidence candidates<br>\n-then use hand label to mark as FP and TP</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1227113,
      "author_name": "something4kag",
      "author_url": "",
      "post_date": "2021-03-05T08:09:08.293000",
      "content": "<p>FYI - see this discussion for requirements for hand labeled / re-annotated train images or external images<br>\n<a href=\"https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644\" target=\"_blank\">https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644</a></p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1227053,
      "author_name": "hengck23",
      "author_url": "",
      "post_date": "2021-03-05T06:18:55.453000",
      "content": "<pre><code>from common import *\nfrom ranzcr import *\n\ndata_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification'\n\ndf_annotation = pd.read_csv(data_dir + '/train_annotations.more.fix.csv')\ndf = pd.read_csv(data_dir + '/train.more.fix.csv')\ndf = df[df.fold!=1]\n\n#-------------------------\nclahe = cv2.createCLAHE(clipLimit=8, tileGridSize=(8, 8))\n#clahe = cv2.createCLAHE(clipLimit=13.5, tileGridSize=(8, 8))\n\n\n# is_a=1  #ground truth\n# dump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/truth'\n# os.makedirs(dump_dir, exist_ok=True)\n# df = df[df.is_annotate==1]\n\nis_a=0\ndump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/try'\nos.makedirs(dump_dir, exist_ok=True)\ndf = df[df.is_annotate==0]\n\n\n#-----------------------------------------\ndf = df.reset_index(drop=True)\nindex = np.arange(len(df))\nfor i in index[:300]:\n    print(i)\n    d = df.iloc[i]\n\n    image = cv2.imread(data_dir+'/train/%s.jpg'%d.StudyInstanceUID, cv2.IMREAD_GRAYSCALE)\n    image = cv2.resize(image, dsize=(768,768), interpolation=cv2.INTER_LINEAR)\n    image = 255-image\n    image = clahe.apply(image)\n\n    is_cvc=0\n    if d[target_col[7]]==1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[7], (5,20), 0.6, 255,1)\n\n    if d[target_col[8]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[8], (5,40), 0.6, 255, 1)\n\n    if d[target_col[9]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[9], (5,60), 0.6, 255, 1)\n    if is_cvc == 0 : continue\n\n    if is_a==1:\n        df_a = df_annotation[df_annotation.StudyInstanceUID==d.StudyInstanceUID]\n        for row in df_a.iterrows():\n            if 'CVC' in row[1].label:\n                point = np.array(eval(row[1].data))*[[768,768]]\n                point = point.astype(np.int32)\n\n                x,y = point[0]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n                x,y = point[-1]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n\n                for x,y in point:\n                    cv2.circle(image,(x,y),1,255,-1,cv2.LINE_AA)\n\n\n    image_show('image', image)\n    cv2.waitKey(1)\n    cv2.imwrite(dump_dir+'/%s.png'%d.StudyInstanceUID,image)\n</code></pre>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1234764,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-03-11T15:06:23.870000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1227050": "i just label difficult cvc cases (endpoint only)\n\n![](https://i.ibb.co/jb5vy1X/Selection-047.png)\n![](https://i.ibb.co/9YX7Y0d/Selection-046.png)\n![](https://i.ibb.co/VY6QJ6n/Selection-048.png)",
    "1227209": "Alternative approach is to use RFCx method:\n-use model to generate high confidence candidates\n-then use hand label to mark as FP and TP",
    "1227113": "FYI - see this discussion for requirements for hand labeled / re-annotated train images or external images\nhttps://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/222644",
    "1227053": "```\nfrom common import *\nfrom ranzcr import *\n\ndata_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification'\n\ndf_annotation = pd.read_csv(data_dir + '/train_annotations.more.fix.csv')\ndf = pd.read_csv(data_dir + '/train.more.fix.csv')\ndf = df[df.fold!=1]\n \n#-------------------------\nclahe = cv2.createCLAHE(clipLimit=8, tileGridSize=(8, 8))\n#clahe = cv2.createCLAHE(clipLimit=13.5, tileGridSize=(8, 8))\n \n\n# is_a=1  #ground truth\n# dump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/truth'\n# os.makedirs(dump_dir, exist_ok=True)\n# df = df[df.is_annotate==1]\n \nis_a=0\ndump_dir = '/root/share1/kaggle/2021/ranzcr/data/ranzcr-clip-catheter-line-classification/hand-label/try'\nos.makedirs(dump_dir, exist_ok=True)\ndf = df[df.is_annotate==0]\n\n\n#-----------------------------------------\ndf = df.reset_index(drop=True)\nindex = np.arange(len(df))\nfor i in index[:300]:\n    print(i)\n    d = df.iloc[i]\n\n    image = cv2.imread(data_dir+'/train/%s.jpg'%d.StudyInstanceUID, cv2.IMREAD_GRAYSCALE)\n    image = cv2.resize(image, dsize=(768,768), interpolation=cv2.INTER_LINEAR)\n    image = 255-image\n    image = clahe.apply(image)\n\n    is_cvc=0\n    if d[target_col[7]]==1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[7], (5,20), 0.6, 255,1)\n\n    if d[target_col[8]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[8], (5,40), 0.6, 255, 1)\n\n    if d[target_col[9]] == 1:\n        is_cvc=1\n        draw_shadow_text(image, target_col[9], (5,60), 0.6, 255, 1)\n    if is_cvc == 0 : continue\n\n    if is_a==1:\n        df_a = df_annotation[df_annotation.StudyInstanceUID==d.StudyInstanceUID]\n        for row in df_a.iterrows():\n            if 'CVC' in row[1].label:\n                point = np.array(eval(row[1].data))*[[768,768]]\n                point = point.astype(np.int32)\n\n                x,y = point[0]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n                x,y = point[-1]\n                cv2.circle(image,(x,y),32,255,2,cv2.LINE_AA)\n\n                for x,y in point:\n                    cv2.circle(image,(x,y),1,255,-1,cv2.LINE_AA)\n\n\n    image_show('image', image)\n    cv2.waitKey(1)\n    cv2.imwrite(dump_dir+'/%s.png'%d.StudyInstanceUID,image)\n\n\n```",
    "1234764": ""
  }
}