第一步、导入需要的包
import os
import scipy.io as sio
import numpy as np
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, u
以读取VOC2012语义分割数据集为例,具体见代码注释:
VocDataset.py
from PIL import Image
import torch
import torch.utils.data as data
import numpy as np
import os
import torchvision
import torchvision.transforms as transforms
import time
#VOC数据集分类对应颜色标签
VOC_COLORMAP = [[0,
使用FastAPI部署用于情绪分析的BERT
使用FastAPI将预训练的BERT模型作为REST API进行情感分析
演示版
该模型经过训练,可以根据Google Play上的应用评论对自定义数据集上的情绪(消极,中立和积极)进行分类。 这是对API的示例请求:
http POST http://127.0.0.1:8000/predict text= " Good basic lists, i would like to create more lists, but the annual