Try  HackMD Logo HackMD

Week 29: 驗證碼大亂鬥前篇

tags: 技術研討

收集資料紀錄

檔名即答案_{亂碼}.png
紅字資料夾名稱暫定移除

資料夾名稱 來源 說明 資料量 大小(MB) 上傳者 圖片範例
random_digit 根元 10525 385.9 信賢
進出口廠商 進出口廠商基本資料查詢 3318 21 信賢
國民身分證 國民身分證領補換資料查詢作業 10528 1184 信賢
醫事 衛生部 醫事查詢系統 pytesseract 辨識成功 2237 13.4 信賢
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
信保 信保基金 pytesseract 辨識成功 10410 7.26 信賢
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
信保2 信保基金 根元登入成功 (已驗證為 ground truth) 14017 12.11 信賢
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
大安 大安運動中心 pytesseract 辨識成功 7810 12.5 信賢
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
emake5000 振興五倍券 pytesseract 辨識成功、疫苗預約平台也是一樣的驗證碼 5,014 59.6 沛筠
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
tnpl_captcha 臺南市立圖書館 點擊圖片後開啟的分頁有解答 8,151 92.5 沛筠
e-Learning 人資系統 原始碼可以直接看到 ground truth src="CaptchaCtrl.ashx?Code=1907089108" 10,001 14.5 昊中
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
假資料 1 (color captcha) 生成假資料 J-Rios/multicolorcaptcha 10,800 42.3 MB 昱睿
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
假資料 2 (模擬台鐵) 生成假資料 JasonLiTW/simple-railway-captcha-solver 11,180 43.6 MB 昱睿
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

其他清單

資料夾名稱 來源 說明 資料量 大小(MB) 上傳者 圖片範例
wracb_captcha 經濟部水利署中區水資源局 點擊圖片後開啟的分頁有解答 8,018 53.5 沛筠
frfa_captcha 舊版農會轉寄好友 圖片網址後五碼 7,028 7.43 沛筠
chiefmail 舊版新竹縣政府縣民信箱 點擊圖片後開啟的分頁有解答 10,075 15.3 沛筠
ntm_captcha 國立臺灣博物館 原始碼可以直接看到 ground truth (alt="請輸入驗證碼xxxx") 10,000 11.2 沛筠

待爬清單 / 歡迎認領 → 目前暫停爬蟲

  • 隨時更新
  • 蒐集完畢後手動將資訊加到上方總表
  • 請注意命名方式和檔案類型
  • 家珍說要一萬張
網站 是否有正解 / 在哪 認領者 進度
郵局中文地址英譯 新視窗內文字 家珍 v
稅籍登記資料公示查詢 統編輸入 86517510 持續查詢 信賢 v(用stt暫不加入)
科技部意見信箱 新視窗內文字 信賢 沒答案
海管志工專區 新視窗內文字 昊中 v
彰化縣政府身心障礙福利服務中心 新視窗內文字 昊中 v
高雄三民地政局 點擊「顯示驗證碼」 昊中 v
桃園市立圖書館 新視窗內文字 沛筠 v
新北市停車費用查詢 新視窗內文字 沛筠 v
高雄市立美術館 點擊「聽取驗證碼」 沛筠 v
舊花蓮縣長信箱 新視窗內文字 家珍 v

Clova Pretrained Model Predict 資料分配

  • 2021/11/22 會後通過的訓練集
  • 之後將分為 case sensitive 和 case insensitive 兩類
  • 2021/11/29 先排除 稅籍登記資料公示查詢
  • 於研發雲上的資料夾為 training_images
  • 2021/12/06 已確認所有檔名符合命名規則 + 補傳郵局驗證碼
網站/資料夾名稱 負責人 張數 正確率 case sensitive
random_digits_images 信賢 0.99427
進出口廠商 信賢 1
身份證 0.99382
信保2 0.99894
臺南市立圖書館 / tnpl_captcha 沛筠 0.98722
e-Learning/elearning_captcha 昊中 0.99852 X
假資料 1/colorful_captcha_images 0.90549
假資料 2/railway_captcha_images 0.79100
郵局中文地址英譯/postmail_captcha 家珍 0.99897
海管志工專區/海管志工專區_captcha 昊中 1 X
彰化縣政府身心障礙福利服務中心/彰化縣政府身心障礙福利服務中心_captcha 昊中 1 X
高雄三民地政局/高雄三民地政局_captcha 昊中 0.93904 X
桃園市立圖書館 / typl_captcha 沛筠 0.99845
新北市停車費用查詢 / parkweb 沛筠 0.98972
高雄市立美術館 / kmfa_captcha 沛筠 0.99287
舊花蓮縣長信箱 / hualien 家珍 0.99638
經濟部水利署中區水資源局 / wracb_captcha 沛筠 0.98947
舊版農會轉寄好友 / frfa_captcha 沛筠 0.99858
舊版新竹縣政府縣民信箱 / chiefmail 沛筠 0.97851
國立臺灣博物館 / ntm_captcha 沛筠 0.99096
  • 找新網站驗證模型(湊到38000張):

    1. 稅籍
    2. 高鐵 -> 難爬
    3. 大安(運動中心)
    4. 臺大醫院
    5. ???

    於研發雲上的資料夾為 testing,進度 5/7

網站 / 資料夾名稱 是否有正解 / 在哪 進度 成效
內政部少年之家 / adh_mohw 新視窗內文字 v
TTQS 人才發展品質管理系統 / ttqs 音檔網址 (需另開視窗) v
南強工商 / ncvs 新視窗內文字 v
國軍高雄總醫院左營分院 / zuoying 新視窗內文字 v
地方產業整合發展計畫 新視窗內文字
新店國民運動中心 音檔 script 標籤裡
農航所影像快照碼查詢 / image_afasi 圖片網址後 4 碼 / 和大安運動中心一致的產出邏輯 v
  • 打包成套件可以import

  • github readme

    1. 有訓練過的網站提供範例圖片
    2. 資料表現如何,給使用者建議
  • 12/27

    1. 改Clova Inference Code (信賢)
    2. 階段性先上,開新repo,信賢撰寫使用規則。
    3. 下一步將新的驗證碼加上去重train。
    4. 學員使用回饋,看需不需要分模型。

關於爬蟲

如果沒有帳密就可能沒有 ground truth,要先 train 一版(懇求大家提供有 ground truth 的資料)

  • selenium 套件介紹:
    Selenium 是為瀏覽器自動化(Browser Automation)需求所設計的一套工具集合,讓程式可以直接驅動瀏覽器進行各種網站操作。

  • selenium 怎麼啟動瀏覽器

    • chromedriver 下載
    • 不囉嗦程式碼給你看
      ​​​​from selenium import webdriver ​​​​chrome = webdriver.Chrome('./chromedriver') ​​​​chrome.get("https://www.facebook.com")
    • 奇技淫巧
      配置 chrome 參數
      ​​​​from selenium.webdriver.chrome.options import Options ​​​​chrome_options = Options() ​​​​# 背景執行 ​​​​chrome_options.add_argument('--headless ​​​​# 谷歌文檔提到需要加上這個屬性來規避bug ​​​​chrome_options.add_argument('--disable-gpu') ​​​​# 為了在登入Facebook後,避免跳出訊息視窗,阻礙之後的自動化執行,可以引用chrome模組底下的Options類別,設定不啟用通知 ​​​​chrome_options.add_argument("--disable-notifications") ​​​​chrome_options.add_argument("--disable-default-apps") ​​​​# 避免 Page Crash 問題 ​​​​chrome_options.add_argument("--disable-dev-shm-usage")
  • selenium 怎麼找你要的東西

    • find_element_by_id
    • find_element_by_name
    • find_element_by_class_name
    • find_element_by_link_text
    • find_element_by_xpath
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • 信保舉例

# 定義驅動程式 driver = webdriver.Chrome(executable_path, options=chrome_options) # 到網頁 driver.get('https://guar.smeg.org.tw/Login.aspx') # 按掉跳出問題 driver.switch_to_alert().accept() # 抓驗證碼 img_ele = driver.find_element_by_xpath('//*[@id="imgCode"]') s = io.BytesIO(img_ele.screenshot_as_png) image = Image.open(s) # 用 pytesseract 辨識 result = pytesseract.image_to_string(image, config=r'--psm 7 -c tessedit_char_whitelist=' + string.ascii_lowercase + string.digits + string.ascii_lowercase)
  • 加碼區
    看到這邊不知道人臉組會不會覺得很無聊,沒關係!
    這邊額外分享一個 IG 爬蟲,可以爬很多帥勾水水
    github 程式碼
    有滾動卷軸無窮盡的解法
    ​​last_height = driver.execute_script("return document.body.scrollHeight") ​​# Scroll down to bottom ​​driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") ​​new_height = driver.execute_script("return document.body.scrollHeight") ​​# Calculate new scroll height and compare with last scroll height ​​if new_height == last_height: ​​ driver.execute_script("window.scrollTo(document.body.scrollHeight,0);") ​​ break
    最後成品

關於模型

v1: 訓練集共 40,579 張、測試集共 1,080 張
v2: 訓練集共 76,148 張、測試集共 1,080 張

模型成效 (v1)

Model Training Acc Testing Acc inferencetime
Clova 0.9195 0.9046 0.06 秒
Focus - 0.9630 0.4 秒
CRNN 0.8 左右 -

模型成效 (v2)

Model Training Acc Testing Acc inferencetime
Focus - 0.8139 0.4 秒

Focus 錯誤的圖片



未來展望

os:一個月後的展望

  • 原本網路上抓的 ground truth 有問題,因此我們先 training 一版模型將有問題的資料作剔除。預計下一次重新 train 一版,並加上 data argumentation。
  • 請大家可以提供想破解的網站驗證碼(僅限用OCR,不包含需要運算)。
    https://www.tabf.org.tw/Organization/Login.aspx
  • 打包成套件,給 RPA track 使用

許願區