2 Star 3 Fork 6

zhaomingming / formula_recognize_20200620

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
OSL-3.0

课程资料以及代码

导航目录

仓库说明

除给班班提交作业代码之外,可以把自己的代码放在 github 上或者 gitee 上,github 连接慢的同学可以放在 gitee 上,gitee 的使用方法与 github 一样,但连接更快。

克隆仓库

git clone https://gitee.com/anjiang2020_admin/formula_recognize_20200620.git

代码提交

git add .
git commit -m "your content"
git push -u origin master

文件目录结构

  • resources: 课程相关资料、电子书、论文等
  • utils: py 实用小工具
  • weekX: 第 X 周课程代码

week17作业[https://gitee.com/anjiang2020_admin/formula_recognize_20200620/tree/master]

作业要求

作业要求
课后作业:
        题目1:  大家可以用自己熟悉的代码试着写一下梯度下降算法。
                 使用自己的代码求y = x^2的最小值
        目的:   体会一下思路到代码的过程。

        题目2:   求y  = (5x_1+3x_2-1)^2+ (-3x_1+-4x_3+1)^2 的最小值。
        目的: 分类器设计基础。

  课堂代码以及资料说明:
   - 图像处理书籍推荐:resources/冈萨雷斯数字图像处理matlab版.pdf
   - 最优化算法书籍推荐:resources/《最优化理论与算法》(第2版)-陈宝林-1.pdf
   - 传统车牌检测代码:week17/week17/carpad_recog
   - 深度学习识别mnist代码:week17/week17/hand_number_recog

week18作业

作业要求

输入图片说明

作业建议步骤以及建议代码:

  1. 数据准备(图片读取,对应的GT生成)[数据这个没有讲,所以代码直接提供,不用填空,代码位置:week18/dataset.py]
  2. EAST 模型建立[填空代码week18/model.py]
  3. loss 函数建立[填空代码week18/loss.py]
  4. 优化函数,超参数选择[填空代码week18/train.py]

开始作业前,建议先下载 VGG 模型预训练权重 pths.zip 和数据集 ICDAR_2015.zip。

ICDAR_2015.zip 密码:wbb6

pths.zip 密码:8pad

下载后解压,将 ICDAR_2015pths 文件夹放入 week18 目录中。

week18作业答案

答案并不惟一,也不一定是最优秀的

  1. 对应答案已上传到week18/loss_0509.py week18/train_0509.py week18/model_0509.py

week19作业

作业要求

  1. 完成locality-aware NMS
  2. 完成EAST模型的前向计算过程

作业建议步骤以及建议代码:

  1. /week19/inference.py 88行,独立完成locality-aware NMS
  2. 完成EAST模型的前向计算过程,输入一张图片,输出其相应结果。

可选作业:

  1. 完成模型的评价测试工作:计算f-socre/h-mean.

作业参考答案

  1. locality-aware-NMS 答案在week19/locality_aware_nms.py
  2. week19/pths下提供了两个模型文件,best.pth与 epoch_10.pth
    • best.pth是训练好的模型,inference.py 调用它后,可得到 week19/res_best.bmp
    • epoch_10.pth是训练到第10个epoch时的模型,inference.py 调用它后,可得到 week19/res_epoch_10.bmp
  3. 可选作业答案:
 1. 参考代码位置:week19/get_f1_score.py
     python get_f1_score.py 可以看到例子
 2. 关于f-score 意义的理解可以参考这里:https://zhuanlan.zhihu.com/p/141033837

week20作业

作业要求

  1. 完成dataloader.py

作业建议步骤以及建议代码

  1. 代码位置:week20/dataloader_0511.py,需要填空的地方:72行, 97行。
  2. 72行是实现公式字符串转换为向量的函数:formulas2tensor
  3. 97是实现公式字符串和公式的图片对应起来的函数,这个主要参考数据集上的readme.
  4. 填写完成后,运行python data_loader_0511.py,得到如下结果为正确: 输入图片说明

开始作业前,从这里下载数据集image2latex100k.zip

20200718之后一周有效:
链接:https://pan.baidu.com/s/1M4agO7c2SEcE9mORzgE-bA  密码:ky0y

关于数据生成思路,可以在这里看看能否收到启发:

week21作业

1. 完成im2latex模型的前向计算程序inference.py,参考代码位置:week21/inference_0520.py

作业建议步骤以及建议代码

  1. 代码位置:week21/inference_0520.py,需要填空的地方:46行, 62行, 89行.
  2. 46行是实现编码器的计算过程
  3. 62是将cnn输出的feature map 转话为 编码器需要的数据格式 成序列的向量,难点时我们还有batch在,要注意。
  4. 89行时实现解码器的计算过程,并实现输出概率p的计算过程。概率是要求在hidden的基础上再使用一个神经网络单元进行计算。
    week21参考答案:week21/inference_20200527.py
    与inference_20200527配套代码:
            week21/data_loader.py
            week21/get_train_data.py

week22作业

1. 完成数据的重新整理(为了尽快让大家训练起来,这里我先提供一份,后续把数据整理代码发出来,数据整理过程确实有点繁琐),数据整理办法:https://github.com/ssampang/im2latex/blob/master/data/prep.sh
2. 完成训练程序(相比inference,训练需要添加loss,然后backward,这些是这个项目的真正难点)
3. 完成基本流程后,需要添加teacher forcing,以看到收敛效果。
4. 总体思路:完成代码后,先完成小批量数据在cpu上的训练,添加后续所有组件,然后再转入gpu,进行大批量数据训练。

       小批量数据训练,验证了我们写的训练代码可以基本闭环,是有效的,为后续大批量数据训练提供基础。

5. 后续需要添加的组件有:[schedule sampling], [row encoder and position embedding], [word embedding],这些组件,我会最近尽快更新上去。

小批量数据训练,验证了我们写的训练代码可以基本闭环,是有效的,为后续大批量数据训练提供基础。 小批量训练效果展示: 输入图片说明 输入图片说明

  作业建议步骤以及建议代码
  1. 数据位置:week22/im2latex_100K_norm_data_split_100M,
       使用方法:
             a 此文件夹内含有6个文件都是以x开头,每个大约90M,将其传入ModelArts 的notebook上使用【点击notebook 页面 upload】
             b 将x开头的文件,同步到teminal里
             c 执行cat_unzip.sh 里面的命令,即可完成数据准备。
  2. 待填空代码位置:week22/train_20200529.py 需要填空的地方在385,193,126,325行。
  3. 385行是实现loss函数的定义,这个函数在193行要使用。
  4. 126行是 随机梯度下降的内容,需要你完成权重的数值的更新。
  5. 325行需要实现teacher forcing功能
  6. 这份代码我在dataloader中做了设置:只训练2张图片,batch_size=2,epoch每次都更新。
  7. 当上传到gpu训练时,需要使用data_loader_whole.py 代替data_loader.py即可。
  

week23作业

1. 先用 BLEU 来评价自己train的model(少量图片)得BLEU,验证训练得闭环性。
2. 验证完成后,使用大量图片进行训练,这时候需要改小学习率,或者使用clip_gradients方法。
3. 使用attnetion结构[dot,product]
4. 使用双lstm结构
    作业建议步骤以及建议代码
    1. 先用baseline模型,训练几个epoch, 查看收敛情况。week23/answer1中为训练代码。week23/pth/中模型文件为训练了4个epoch的模型参数文件。
    2. 更换sgd 为momentum + L2正则化
    3. 使用双lstm结构
    4.  使用 attention结构
    5. 使用clip_gradients方法
    6. 使用词向量
    7.使用multi-head attention

week24作业

 1.将我们训练得到的两个模型:east和im2latex部署到webserver上。
   作业建议步骤以及建议代码
   1.参考模型部署的工程代码:https://gitee.com/anjiang2020_admin/bd_cv3_webserver_demo

更新日志

20200810:

  1. 添加week21,22,23课后作业答案

20200706:

  1. 添加week18作业参考代码

20200621:

  1. 添加week17作业,课堂代码与课堂资料

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

码云特技

  1. 使用 README_XX.md 来支持不同的语言,例如 README_en.md, README_zh.md
  2. 码云官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解码云上的优秀开源项目
  4. GVP 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
  5. 码云官方提供的使用手册 https://gitee.com/help
  6. 码云封面人物是一档用来展示码云会员风:采的栏目 https://gitee.com/gitee-stars/
Open Software License ("OSL") v 3.0 This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: Licensed under the Open Software License version 3.0 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: a) to reproduce the Original Work in copies, either alone or as part of a collective work; b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; d) to perform the Original Work publicly; and e) to display the Original Work publicly. 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

简介

课堂代码与作业同步地址 展开 收起
Python
OSL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/anjiang2020_admin/formula_recognize_20200620.git
git@gitee.com:anjiang2020_admin/formula_recognize_20200620.git
anjiang2020_admin
formula_recognize_20200620
formula_recognize_20200620
master

搜索帮助