Comments (10)
Inference参考这里:https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/altclip_inference.py
可以用如下的代码加载模型权重
model_save_path = "xxx"
model.load_state_dict(torch.load(model_save_path, map_location="cuda")["module"])
from flagai.
Inference参考这里:https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/altclip_inference.py 可以用如下的代码加载模型权重 model_save_path = "xxx" model.load_state_dict(torch.load(model_save_path, map_location="cuda")["module"])
@BAAI-OpenPlatform train 的时候可以使用valid_dataset进行metric_methods计算吗 如下是否可执行
trainer.train(model=model, train_dataset = dl, valid_dataset=vdl, metric_methods=[["top1_acc", "top5_acc"]], optimizer = torch.optim.SGD(model.parameters(), lr=1e-3))
from flagai.
AltCLIP的evaluation可以参考https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/AltCLIP_evaluation.py
其他模型的evaluation一般来说是这样子的:
可以在Trainer初始化的时候添加一行 eval_interval=10,
from flagai.methics import accuracy_metric
然后trainer.train()里插入:metric_method=[("accuracy", accuracy_metric)]
from flagai.
AltCLIP的evaluation可以参考https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/AltCLIP_evaluation.py 其他模型的evaluation一般来说是这样子的:
可以在Trainer初始化的时候添加一行 eval_interval=10, from flagai.methics import accuracy_metric 然后trainer.train()里插入:metric_method=[("accuracy", accuracy_metric)]
@BAAI-OpenPlatform 有错误
│ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:1108 in │
│ evaluate_and_print_results │
│ │
│ 1105 │ ): │
│ 1106 │ │ """Helper function to evaluate and dump results on screen.""" │
│ 1107 │ │ │
│ ❱ 1108 │ │ eval_dict = self.evaluate(forward_step_func=forward_step_func, │
│ 1109 │ │ │ │ │ │ │ │ data_loader=data_loader, │
│ 1110 │ │ │ │ │ │ │ │ model=model, │
│ 1111 │ │ │ │ │ │ │ │ verbose=verbose) │
│ │
│ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:971 in evaluate │
│ │
│ 968 │ │ # Turn on evaluation mode which disables dropout. │
│ 969 │ │ tmp_model.eval() │
│ 970 │ │ if hasattr(tmp_model, │
│ ❱ 971 │ │ │ │ 'config') and 'checkpoint_activations' in tmp_model.config: │
│ 972 │ │ │ tmp_checkpoint_activations = tmp_model.config[ │
│ 973 │ │ │ │ 'checkpoint_activations'] │
│ 974 │ │ │ tmp_model.config['checkpoint_activations'] = False │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: argument of type 'AltCLIPConfig' is not iterable
下面代码是我的trainer:
trainer = Trainer(env_type="pytorch",
pytorch_device=device,
experiment_name="clip_finetuning",
batch_size=batch_size,
lr=1e-4,
epochs=20,
fp16=True,
eval_interval=10,
log_interval=50)
trainer.train(model=model, train_dataset = dl, valid_dataset=vdl, metric_methods=[("accuracy", accuracy_metric)], optimizer = torch.optim.SGD(model.parameters(), lr=1e-3))
from flagai.
AltCLIP的evaluation可以参考https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/AltCLIP_evaluation.py 其他模型的evaluation一般来说是这样子的:
可以在Trainer初始化的时候添加一行 eval_interval=10, from flagai.methics import accuracy_metric 然后trainer.train()里插入:metric_method=[("accuracy", accuracy_metric)]@BAAI-OpenPlatform 有错误 │ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:1108 in │ │ evaluate_and_print_results │ │ │ │ 1105 │ ): │ │ 1106 │ │ """Helper function to evaluate and dump results on screen.""" │ │ 1107 │ │ │ │ ❱ 1108 │ │ eval_dict = self.evaluate(forward_step_func=forward_step_func, │ │ 1109 │ │ │ │ │ │ │ │ data_loader=data_loader, │ │ 1110 │ │ │ │ │ │ │ │ model=model, │ │ 1111 │ │ │ │ │ │ │ │ verbose=verbose) │ │ │ │ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:971 in evaluate │ │ │ │ 968 │ │ # Turn on evaluation mode which disables dropout. │ │ 969 │ │ tmp_model.eval() │ │ 970 │ │ if hasattr(tmp_model, │ │ ❱ 971 │ │ │ │ 'config') and 'checkpoint_activations' in tmp_model.config: │ │ 972 │ │ │ tmp_checkpoint_activations = tmp_model.config[ │ │ 973 │ │ │ │ 'checkpoint_activations'] │ │ 974 │ │ │ tmp_model.config['checkpoint_activations'] = False │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: argument of type 'AltCLIPConfig' is not iterable
下面代码是我的trainer: trainer = Trainer(env_type="pytorch", pytorch_device=device, experiment_name="clip_finetuning", batch_size=batch_size, lr=1e-4, epochs=20, fp16=True, eval_interval=10, log_interval=50) trainer.train(model=model, train_dataset = dl, valid_dataset=vdl, metric_methods=[("accuracy", accuracy_metric)], optimizer = torch.optim.SGD(model.parameters(), lr=1e-3))
您好,能否发一下accuracy_metric这个函数?
from flagai.
AltCLIP的evaluation可以参考https://github.com/FlagAI-Open/FlagAI/blob/master/examples/AltCLIP/AltCLIP_evaluation.py 其他模型的evaluation一般来说是这样子的:
可以在Trainer初始化的时候添加一行 eval_interval=10, from flagai.methics import accuracy_metric 然后trainer.train()里插入:metric_method=[("accuracy", accuracy_metric)]@BAAI-OpenPlatform 有错误 │ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:1108 in │ │ evaluate_and_print_results │ │ │ │ 1105 │ ): │ │ 1106 │ │ """Helper function to evaluate and dump results on screen.""" │ │ 1107 │ │ │ │ ❱ 1108 │ │ eval_dict = self.evaluate(forward_step_func=forward_step_func, │ │ 1109 │ │ │ │ │ │ │ │ data_loader=data_loader, │ │ 1110 │ │ │ │ │ │ │ │ model=model, │ │ 1111 │ │ │ │ │ │ │ │ verbose=verbose) │ │ │ │ C:\Users\bigdata\AppData\Roaming\Python\Python38\site-packages\flagai\trainer.py:971 in evaluate │ │ │ │ 968 │ │ # Turn on evaluation mode which disables dropout. │ │ 969 │ │ tmp_model.eval() │ │ 970 │ │ if hasattr(tmp_model, │ │ ❱ 971 │ │ │ │ 'config') and 'checkpoint_activations' in tmp_model.config: │ │ 972 │ │ │ tmp_checkpoint_activations = tmp_model.config[ │ │ 973 │ │ │ │ 'checkpoint_activations'] │ │ 974 │ │ │ tmp_model.config['checkpoint_activations'] = False │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: argument of type 'AltCLIPConfig' is not iterable
下面代码是我的trainer: trainer = Trainer(env_type="pytorch", pytorch_device=device, experiment_name="clip_finetuning", batch_size=batch_size, lr=1e-4, epochs=20, fp16=True, eval_interval=10, log_interval=50) trainer.train(model=model, train_dataset = dl, valid_dataset=vdl, metric_methods=[("accuracy", accuracy_metric)], optimizer = torch.optim.SGD(model.parameters(), lr=1e-3))您好,能否发一下accuracy_metric这个函数?
from flagai.metrics import accuracy_metric
我这边把 train里的验证集去掉 换成下面的形式就可以运行了
trainer.train(model=model, train_dataset = dl, metric_methods=[("accuracy", accuracy_metric)], optimizer = torch.optim.SGD(model.parameters(), lr=1e-3))
我的验证集和训练集的构建方式是一样的 只是取了不同范围的数据 @920232796
from flagai.
@BAAI-OpenPlatform 关于使用altcllip训练自己的数据集 能给一个带metric_methods的例子吗
from flagai.
@BAAI-OpenPlatform 关于使用altcllip训练自己的数据集 能给一个带metric_methods的例子吗
一般这种任务的话,验证是可以选择另外的一个数据集,而且针对不同数据集类型,分为分类和检索,不同数据集类型的验证方式也不一样,这里推荐您可以尝试一下分类的,比较简单,例如可以选择CIFAR-10,CIFAR-100,或者Imagenet的验证集。具体代码您可以看一下examples/AltCLIP/AltCLIP_evaluation.py 。
如果您使用相同的数据集,那么应该就是检索类(图文),这块您可以参考这个代码进行修改:https://github.com/LAION-AI/CLIP_benchmark/blob/main/clip_benchmark/metrics/zeroshot_retrieval.py
from flagai.
@BAAI-OpenPlatform 关于使用altcllip训练自己的数据集 能给一个带metric_methods的例子吗
一般这种任务的话,验证是可以选择另外的一个数据集,而且针对不同数据集类型,分为分类和检索,不同数据集类型的验证方式也不一样,这里推荐您可以尝试一下分类的,比较简单,例如可以选择CIFAR-10,CIFAR-100,或者Imagenet的验证集。具体代码您可以看一下examples/AltCLIP/AltCLIP_evaluation.py 。
如果您使用相同的数据集,那么应该就是检索类(图文),这块您可以参考这个代码进行修改:https://github.com/LAION-AI/CLIP_benchmark/blob/main/clip_benchmark/metrics/zeroshot_retrieval.py
我这边训练数据用的是自己整理的图/文数据 ,并没有对应的label ,这种情况下 我在train方法里 如何指定 验证数据集 以及如何 选择metric_methods
from flagai.
可以的,你这个数据就是相当于我说的retrieval,labels应该就是图像对应的文本吧,然后其他图像当作负样本,所以train函数中,传入val_dataset以后,metric_methods需要参考我发给您的那个retrieval代码来写。
from flagai.
Related Issues (20)
- [Question]: 如何进行模型并行训练 HOT 2
- 怎么加载altclip模型? HOT 5
- [Question]: Lora微调 HOT 3
- [Question]: modehub中的altclip与huggingface上的altclip参数不一致 HOT 4
- [Question]: UnboundLocalError: local variable 'model_id' referenced before assignment
- [Question]: Model hub is not reachable! HOT 4
- [Question]: altclip直接运行example的inference.py报错KeyError: 'text_config' HOT 2
- [Question]: How to train the altclip model
- AquilaChat2 34B推理问题 HOT 1
- [Question]: 使用flagai AutoLoader加载AquilaChat2-7B-16K,输入英文 输出乱码 HOT 2
- 运行对话脚本aquilachat2-34b-16k 报错误 HOT 1
- Collecting PyYAML==5.4.1 (from flagai)报错 HOT 4
- [Question]: No module named 'packaging' This question is after install NVIDIA's apex HOT 1
- torchrun command not found HOT 5
- [Question]: 想问下AquilaDecoderLayer里的传参为什么是float的?这样是用的float类型的attention HOT 2
- Can't run examples/vit_cifar100/train_deepspeed.py HOT 1
- TypeError: AquilaPreTrainedModel._set_gradient_checkpointing() got an unexpected keyword argument 'enable' HOT 2
- How does one obtain training data suitable for fine-tuning Aquila models? HOT 2
- [Question]: 请问AltCLIP有没有提供使用Flickr30k微调及评估的脚本
- Do you have this dataset?[Question]:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flagai.