Giter Club home page Giter Club logo

Comments (2)

seastarmanager avatar seastarmanager commented on August 19, 2024

如果是通过文件的话,你可以自己仿照my_dataset.py里面的get_xxxx_data_loader,去做一个自己的dataloader,就类似于predict的时候差不多。

如果是PIL读入的图片的话,可以参考pytorch的api,用transform把图片变灰度图,变尺寸,转成tensor。然后对tensor进行reshape把图片的三维tensor变成模型需要的四维的。
然后仿照captcha_predict.py的代码,把图片的tensor变成Variable,然后调用cnn的模型进行前向传播,然后再把onehot形式的label按4个位置分别取最大值,最后输出4个字符的结果。

from pytorch-captcha-recognition.

asyncins avatar asyncins commented on August 19, 2024

实在不会用,用captcha_predict.py可以,但是我想在其它地方单独传入一张图片名称得到返回结果如何做呢?

实际使用时,并不是从本地文件夹打开,而很有可能直接传一张图片。所以你需要按照 seastarmanager 的建议,将图片进行特征数字化、归一化和灰度处理。要注意的是,图片尺寸大小的兼容问题。假如你训练的时候用的是 160*60,那么在预测时也要用这个大小。

from pytorch-captcha-recognition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.