一个新的计算机视觉图书馆

pytorch-fanatics的Python项目详细描述


皮托奇狂热分子

Pythorch iu Fanatics是一个便于计算机视觉的Python库任务。这个包含一堆不同的工具,将有助于创建自定义代码来训练CV模型。在

此库包括:

  • 数据集类
  • 激光测距仪
  • 早起
  • 培训师
  • 记录器

安装

使用包管理器pip安装Pythorch\u狂热者。在

pip install pytorch_fanatics

使用

1)数据集类

^{pr2}$

2)测距仪

frompytorch_fanatics.utilsimportLRFinderlr_finder=LRFinder(model,train_dataloader,optimizer,device,initial_lr,final_lr,beta)#Create a objectlr_finder.find()#To find the lrlr_finder.plot()#To plot the graph (Loss V/S lr)#NOTE:#Use this only after training the model with all layers (except the last) freezed.

3)早顶

frompytorch_fanatics.utilsimportEarlyStopes=EarlyStop(patience=7,mode="max",delta=0.0001)#Create a objectes(epoch_score,model,path)ifes.early_stop=True:breakes.reset()# to reset

4)培训师

frompytorch_fanatics.trainerimportTrainerTrainer.train(model,data_loader,optimizer,device)# trains the modelscore=Trainer.evaluate(model,data_loader,device,scheduler=None,metric=metrics.accuracy_score,plot=True)#Use the score to feed for earlystop if used#plot=True specifies live plot b/w (training and validation) vs num_epochsTrainer.predict(model,data_loader,device)# returns probability of classesTrainer.get_log()#returns a DataFrame object of logs #Currently the metrics supported are f1_score,accuracy,precision,recall,roc_auc_score and log_loss#We are working on other too ..

5)记录器

frompytorch_fanatics.loggerimportLoggerLogger.save(model,optimizer,scheduler,path)# saves model,optimizer and schedulers#To load:checkpoint=Logger.load(path)#returns a dictionarymodel,optimizer,scheduler=checkpoint['model'],checkpoint['optimizer'],checkpoint['scheduler']#Helps keep track of training.It will restart from where it had stopped.

NOTE(关于型号)

classResnet18(nn.Module):def__init__(self):super(Resnet18,self).__init__()self.base_model=timm.create_model('resnet18',pretrained=True,num_classes=1)defforward(self,image,targets):batch_size,_,_,_=image.shapeout=self.base_model(image)loss=nn.BCEWithLogitsLoss()(out.view(batch_size,),targets.type_as(out))returnout,loss#Since every loss function has its own format of inputs,To generalise I have created this model.Use this model(edit if required) if you are #using Trainer/LRFinder.For others your simple model will also work fine..

贡献

欢迎拉取请求。对于重大变化,请先打开一个问题,讨论您希望更改的内容。在

请确保根据需要更新测试。在

许可证

MIT

参考文献

  • LRFinder的FastAi文档。在
  • Pythorch文件。在
  • 阿披实克塔库先生的Github项目wtfml(很棒的工作也可以看看)。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java通过Spring MVC web应用程序向客户端发送文本文件   java是否可以在运行时动态实例化DAO类?   调用VB。来自Java的net函数   java在Android中通过单击打开特定文件夹   java如何使用maven pom。xml标识非标准项目结构中的testng测试用例?   java为什么FOP在大文件上崩溃?   Architecture python+flask和spring boot+java   java Kafka工具根本没有启动Ubuntu 19.10   如何使用Eclipse运行Java USB API for Windows   java如何在Eclipse中查看J2EE预览服务器/容器的日志/控制台?   网页抓取是否可以使用Java crawler crawler4j暂停和恢复抓取?   java当我第二次按下按钮时,应用程序停止工作   带有偏移量和限制的java SQLite分页问题   java如何在OSX mavericks中将端口80转发到8080   java从泛型方法调用非泛型方法   java My代码未按预期工作。十进制输出不是它应该的样子   节点。java中的js加密(jasypt)和nodejs中的解密   java乘法表不工作数组索引超出范围   java将JDBC与Firebirdsql连接起来