from PyPDF2 import PdfReader
reader = PdfReader(pdf_path)
number_of_pages = len(reader.pages)
print(number_of_pages)
page = reader.pages[0]
print(page)
text = page.extract_text()
print(text)
{'/Contents': IndirectObject(13, 0), '/Parent': IndirectObject(1, 0), '/Type': '/Page', '/Resources': IndirectObject(14, 0), '/MediaBox': [0, 0, 612, 792]}
ImageNet Classication with Deep Convolutional
Neural Networks
Alex Krizhevsky
University of Toronto
kriz@cs.utoronto.ca
Ilya Sutskever
University of Toronto
ilya@cs.utoronto.ca
Geoffrey E. Hinton
University of Toronto
hinton@cs.utoronto.ca
Abstract
We trained a large, deep convolutional neural network to classify the 1.2 million
high-resolution images in the ImageNet LSVRC-2010 contest into the 1000 dif-
ferent classes. On the test data, we achieved top-1 and top-5 error rates of 37.5%
and 17.0% which is considerably better than the previous state-of-the-art. The
neural network, which has 60 million parameters and 650,000 neurons, consists
of ve convolutional layers, some of which are followed by max-pooling layers,
and three fully-connected layers with a nal 1000-way softmax. To make train-
ing faster, we used non-saturating neurons and a very efcient GPU implemen-
tation of the convolution operation. To reduce overtting in the fully-connected
layers we employed a recently-developed regularization method called fidropoutfl
that proved to be very effective. We also entered a variant of this model in the
ILSVRC-2012 competition and achieved a winning top-5 test error rate of 15.3%,
compared to 26.2% achieved by the second-best entry.
1 Introduction
Current approaches to object recognition make essential use of machine learning methods. To im-
prove their performance, we can collect larger datasets, learn more powerful models, and use bet-
ter techniques for preventing overtting. Until recently, datasets of labeled images were relatively
small Š on the order of tens of thousands of images (e.g., NORB [16], Caltech-101/256 [8, 9], and
CIFAR-10/100 [12]). Simple recognition tasks can be solved quite well with datasets of this size,
especially if they are augmented with label-preserving transformations. For example, the current-
best error rate on the MNIST digit-recognition task (<0.3%) approaches human performance [4].
But objects in realistic settings exhibit considerable variability, so to learn to recognize them it is
necessary to use much larger training sets. And indeed, the shortcomings of small image datasets
have been widely recognized (e.g., Pinto et al. [21]), but it has only recently become possible to col-
lect labeled datasets with millions of images. The new larger datasets include LabelMe [23], which
consists of hundreds of tho usands of fully-segmented images, and ImageNet [6], which consists of
over 15 million labeled high-resolution images in over 22,000 categories.
To learn about thousands of objects from millions of images, we need a model with a large learning
capacity. However, the immense complexity of the object recognition task means that this prob-
lem cannot be specied even by a dataset as large as ImageNet, so our model should also have lots
of prior knowledge to compensate for all the data we don't have. Convolutional neural networks
(CNNs) constitute one such class of models [16, 11, 13, 18, 15, 22, 26]. Their capacity can be con-
trolled by varying their depth and breadth, and they also make strong and mostly correct assumptions
about the nature of images (namely, stationarity of statistics and locality of pixel dependencies).
Thus, compared to standard feedforward neural networks with similarly-sized layers, CNNs have
much fewer connections and parameters and so they are easier to train, while their theoretically-best
performance is likely to be only slightly worse.
可以看到页数和PDF中的文字都能正确提取出来。
PDF是文档常用格式,使用Python包PyPDF2可以对PDF文档实现批量、迅速的操作,包括提取文字、切分或合并PDF文件、创建annotation、加密和解密等。本文将介绍PyPDF2包的安装及简单使用方式。
PyPDF2–如何使用python操作你的PDF文档
大家好!最近想操作一下PDF文档,总是收费,于是浅尝辄止地了解了一下python当中的PyPDF2这个库。借助本篇博客总结了一下个人所学到的内容。本人才疏学浅,还望各位大佬多多指正。Python在自动化办公方面有很多实用的第三方库,可以很方便的处理word、excel、ppt、pdf文件,Python处理PDF文档的两个常用库pdfplumber,PyPDF2。在此本人对PyPDF2进行一个简单的介绍。
0.0:PyPDF2简介以及安装
PyPDF
在PyPDF2中使用PdfFileWriter类,可以添加一个空白页。
示例代码:
from PyPDF2 import PdfFileReader, PdfFileWriter
# 创建一个PdfFileReader对象
pdf_reader =PdfFileReader(pdf_file)
# 创建一个PdfFileWriter对象
pdf_writer = PdfFileWriter()...
Python系列 之 PyPDF2库 学习
PyPDF2中主要涉及到的几个对象有 PdfFileReader、PdfFileWriter和PdfFileMerger以及PageObject
PdfFileReader
PdfFileReader对象:
import PyPDF2
PyPDF2.PdfFileReader(stream , strict=True , warndest=None , overwriteWarnings=True))
# stream :一个 File 对象或支持类似于