updating VAERS data

This commit is contained in:
frankknoll
2023-03-18 02:04:28 +01:00
parent 2aef84ab9b
commit 1f2c8f401e
1656 changed files with 1741 additions and 1649 deletions

View File

@@ -14,22 +14,31 @@ from captcha.CaptchaShape import CaptchaShape
# textInCaptchaImage = ! adb shell "run-as org.textrecognizer cat /data/data/org.textrecognizer/files/captcha_image.txt"
# return textInCaptchaImage[0]
def solveCaptchaAndStartFileDownload(driver, captchaImageFile):
saveCaptchaImageAs(driver, captchaImageFile)
textInCaptchaImage = _createCaptchaReader().getTextInCaptchaImage(captchaImageFile)
print('textInCaptchaImage:', textInCaptchaImage)
driver.find_element(By.ID, "verificationCode").send_keys(textInCaptchaImage)
driver.find_element(By.CSS_SELECTOR, '[name="downloadbut"]').click()
def updateVAERSFiles(years, workingDirectory):
for year in years:
downloadVAERSFileAndUnzip(f'{year}VAERSData.zip', workingDirectory)
downloadVAERSFileAndUnzip('NonDomesticVAERSData.zip', workingDirectory)
def downloadVAERSFileAndUnzip(file, workingDirectory):
downloadedFile = downloadVAERSFile(file, workingDirectory + "/VAERS/tmp")
unzipAndRemove(
zipFile = downloadedFile,
dstDir = workingDirectory + '/VAERS/')
def _createCaptchaReader():
working_directory = os.path.dirname(__file__)
return CaptchaReader(modelFilepath = f'{working_directory}/captcha/MobileNetV3Small',
captchaShape = CaptchaShape())
def downloadVAERSFile(file, downloadDir):
driver = getWebDriver(downloadDir, isHeadless = False)
downloadedFile = downloadFile(
absoluteFile = downloadDir + "/" + file,
driver = driver,
maxTries = None)
driver.quit()
return downloadedFile
def downloadFile(absoluteFile, driver, maxTries):
captchaReader = _createCaptchaReader()
def _downloadFile():
driver.get('https://vaers.hhs.gov/eSubDownload/index.jsp?fn=' + os.path.basename(absoluteFile))
solveCaptchaAndStartFileDownload(driver, 'captchaImage.jpeg')
solveCaptchaAndStartFileDownload(driver, captchaReader, 'captchaImage.jpeg')
numTries = 1
_downloadFile()
@@ -43,26 +52,18 @@ def downloadFile(absoluteFile, driver, maxTries):
else:
return None
def _createCaptchaReader():
working_directory = os.path.dirname(__file__)
return CaptchaReader(modelFilepath = f'{working_directory}/captcha/MobileNetV3Small',
captchaShape = CaptchaShape())
def solveCaptchaAndStartFileDownload(driver, captchaReader, captchaImageFile):
saveCaptchaImageAs(driver, captchaImageFile)
textInCaptchaImage = captchaReader.getTextInCaptchaImage(captchaImageFile)
print('textInCaptchaImage:', textInCaptchaImage)
driver.find_element(By.ID, "verificationCode").send_keys(textInCaptchaImage)
driver.find_element(By.CSS_SELECTOR, '[name="downloadbut"]').click()
def _waitUntilDownloadHasFinished(file):
while not os.path.exists(file):
time.sleep(2)
def downloadVAERSFile(file, downloadDir):
driver = getWebDriver(downloadDir, isHeadless = True)
downloadedFile = downloadFile(
absoluteFile = downloadDir + "/" + file,
driver = driver,
maxTries = None)
driver.quit()
return downloadedFile
def downloadVAERSFileAndUnzip(file, workingDirectory):
downloadedFile = downloadVAERSFile(file, workingDirectory + "/VAERS/tmp")
unzipAndRemove(
zipFile = downloadedFile,
dstDir = workingDirectory + '/VAERS/')
def updateVAERSFiles(years, workingDirectory):
for year in years:
downloadVAERSFileAndUnzip(f'{year}VAERSData.zip', workingDirectory)
downloadVAERSFileAndUnzip('NonDomesticVAERSData.zip', workingDirectory)
time.sleep(2)

View File

@@ -11,8 +11,8 @@ from tensorflow import keras
class CaptchaReader:
def __init__(self, modelFilepath, captchaShape):
self.modelFilepath = modelFilepath
self.captchaShape = captchaShape
self.predictionModel = self._createPredictionModel(modelFilepath)
def getTextInCaptchaImage(self, captchaImageFile):
return self._getTextsInCaptchaImage(self._getCaptchaImage(captchaImageFile))[0]
@@ -24,8 +24,8 @@ class CaptchaReader:
return np.expand_dims(keras.utils.img_to_array(img), axis=0)
def _getTextsInCaptchaImage(self, captchaImage):
preds = self._createPredictionModel().predict(captchaImage)
preds = self.predictionModel.predict(captchaImage)
return PredictionsDecoder(CaptchaGenerator.captchaLength, CharNumConverter(CaptchaGenerator.characters).num_to_char).decode_batch_predictions(preds)
def _createPredictionModel(self):
return ModelFactory.createPredictionModel(ModelDAO().loadModel(self.modelFilepath))
def _createPredictionModel(self,modelFilepath):
return ModelFactory.createPredictionModel(ModelDAO().loadModel(modelFilepath))

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.