当前位置: 首页 > news >正文

部署系列六基于nndeploy的深度学习 图像降噪unet部署

文章目录

    • 1.直接在源代码demo中修改
    • 2. 如何修改呢?
      • 3. 修改 graph
      • 4. 总结

https://github.com/DeployAI/nndeploy
https://nndeploy-zh.readthedocs.io/zh/latest/introduction/index.html

通过以上2个官方链接对nndeploy基本的使用方法应该有所了解了。
下面就是利用nndeploy跑一个图像降噪的unet类型网络。

为了方便,直接修改源码然后重新编译了一个demo。大家理解就好,可以自己整理完善,创建新的demo, 因为我这里没有创建新的deno,而是直接修改 yolov5的相关代码。

1.直接在源代码demo中修改

源代码如果你想运行yolo5是一个目标检测模型,可以通过下面的命令:
onnxruntime:115ms
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeOnnxRuntime --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeOnnx --is_path --model_value …/…/yolov5s.onnx --input_type kInputTypeImage --input_path …/…/sample.jpg --output_path …/…/sample_output.jpg

openvino:57ms
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeOpenVino --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeOnnx --is_path --model_value …/…/yolov5s.onnx --input_type kInputTypeImage --input_path …/…/sample.jpg --output_path …/…/sample_output.jpg

mnn:78ms
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeMnn --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeMnn --is_path --model_value …/…/yolov5s.mnn --input_type kInputTypeImage --input_path …/…/sample.jpg --output_path …/…/sample_output.jpg

tensorrt: 17ms
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeTensorRt --device_type kDeviceTypeCodeCuda:0 --model_type kModelTypeOnnx --is_path --model_value …/…/yolov5s.onnx --input_type kInputTypeImage --input_path …/…/sample.jpg --output_path …/…/sample_output.jpg

然后我直接修改源码然后编译后通过下面的命令 可以运行 unet denoise model

tensorrt
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeTensorRt --device_type kDeviceTypeCodeCuda:0 --model_type kModelTypeOnnx --is_path --model_value /home/tony/nndeploy/mymodel/scripts/unet8.opt.onnx --input_type kInputTypeImage --input_path …/…/1007_01_06_40_000101.png --output_path …/…/sample_output.jpg

onnxruntime
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeOnnxRuntime --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeOnnx --is_path --model_value /home/tony/nndeploy/mymodel/scripts/unet8.opt.onnx --input_type kInputTypeImage --input_path …/…/1007_01_06_40_000101.png --output_path …/…/sample_output.jpg

openvino:
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeOpenVino --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeOnnx --is_path --model_value /home/tony/nndeploy/mymodel/scripts/unet8.opt.onnx --input_type kInputTypeImage --input_path …/…/1007_01_06_40_000101.png --output_path …/…/sample_output.jpg

MNN:
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeMnn --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeMnn --is_path --model_value /home/tony/nndeploy/mymodel/scripts/unet8.opt.mnn --input_type kInputTypeImage --input_path …/…/1007_01_06_40_000101.png --output_path …/…/sample_output.jpg

TNN:
./install/lib/demo_nndeploy_detect --name NNDEPLOY_YOLOV5 --inference_type kInferenceTypeTnn --device_type kDeviceTypeCodeX86:0 --model_type kModelTypeTnn --is_path --model_value /home/tony/nndeploy/mymodel/scripts/unet8.sim.tnnproto,/home/tony/nndeploy/mymodel/scripts/unet8.sim.tnnmodel --input_type kInputTypeImage --input_path …/…/1007_01_06_40_000101.png --output_path …/…/sample_output.jpg

2. 如何修改呢?

首先明白我的模型,输入输出都是 c,h,w, 0-1, float32
首先修改demo.cc:
设置了graph的 input和output :都是 h, w, c , 0-1, float32
输入是 h,w,c float32
输出也是h,w,c float32

一个完整的graph包括:

  1. 前处理需要完成 从 h,w,c foat32 -> c, h, w float32
    2.然后infer跑model;:输入输出都是 c,h,w, 0-1, float32
    3.那么后处理需要完成 从 c, h, w,float32 -> h, w, c, float32

其实使用一个框架,要获取到 模型输入和输出的指针,然后可以用opencv进行前后预处理,很多框架都有自己的前后处理(我不太喜欢用,感觉不清晰有学习成本)
在这里插入图片描述
完整代码:

#include "flag.h"
#include "nndeploy/base/glic_stl_include.h"
#include "nndeploy/base/time_profiler.h"
#include "nndeploy/dag/node.h"
#include "nndeploy/device/device.h"
#include "nndeploy/model/detect/yolo/yolo.h"using namespace nndeploy;cv::Mat drawBox(cv::Mat &cv_mat, model::DetectResult &result) {// float w_ratio = float(cv_mat.cols) / float(640);// float h_ratio = float(cv_mat.rows) / float(640);float w_ratio = float(cv_mat.cols);float h_ratio = float(cv_mat.rows);const int CNUM = 80;cv::RNG rng(0xFFFFFFFF);cv::Scalar_<int> randColor[CNUM];for (int i = 0; i < CNUM; i++)rng.fill(randColor[i], cv::RNG::UNIFORM, 0, 256);int i = -1;for (auto bbox : result.bboxs_) {std::array<float, 4> box;box[0] = bbox.bbox_[0];  // 640.0;box[2] = bbox.bbox_[2];  // 640.0;box[1] = bbox.bbox_[1];  // 640.0;box[3] = bbox.bbox_[3];  // 640.0;box[0] *= w_ratio;box[2] *= w_ratio;box[1] *= h_ratio;box[3] *= h_ratio;int width = box[2] - box[0];int height = box[3] - box[1];int id = bbox.label_id_;NNDEPLOY_LOGE("box[0]:%f, box[1]:%f, width :%d, height :%d\n", box[0],box[1], width, height);cv::Point p = cv::Point(box[0], box[1]);cv::Rect rect = cv::Rect(box[0], box[1], width, height);cv::rectangle(cv_mat, rect, randColor[id]);std::string text = " ID:" + std::to_string(id);cv::putText(cv_mat, text, p, cv::FONT_HERSHEY_PLAIN, 1, randColor[id]);}return cv_mat;
}//
int main(int argc, char *argv[]) {gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true);if (demo::FLAGS_usage) {demo::showUsage();return -1;}// 检测模型的有向无环图graph名称,例如:// NNDEPLOY_YOLOV5/NNDEPLOY_YOLOV6/NNDEPLOY_YOLOV8std::string name = demo::getName();// 推理后端类型,例如:// kInferenceTypeOpenVino / kInferenceTypeTensorRt / kInferenceTypeOnnxRuntimebase::InferenceType inference_type = demo::getInferenceType();// 推理设备类型,例如:// kDeviceTypeCodeX86:0/kDeviceTypeCodeCuda:0/...base::DeviceType device_type = demo::getDeviceType();// 模型类型,例如:// kModelTypeOnnx/kModelTypeMnn/...base::ModelType model_type = demo::getModelType();// 模型是否是路径bool is_path = demo::isPath();// 模型路径或者模型字符串std::vector<std::string> model_value = demo::getModelValue();// 有向无环图graph的输入边packertdag::Edge input("detect_in");// 有向无环图graph的输出边packertdag::Edge output("detect_out");// 创建检测模型有向无环图graphdag::Graph *graph =dag::createGraph(name, inference_type, device_type, &input, &output,model_type, is_path, model_value);if (graph == nullptr) {NNDEPLOY_LOGE("graph is nullptr");return -1;}// 初始化有向无环图graphNNDEPLOY_TIME_POINT_START("graph->init()");base::Status status = graph->init();if (status != base::kStatusCodeOk) {NNDEPLOY_LOGE("graph init failed");return -1;}NNDEPLOY_TIME_POINT_END("graph->init()");// 有向无环图graph的输入图片路径std::string input_path = demo::getInputPath();// opencv读图cv::Mat input_mat = cv::imread(input_path);int img_h = input_mat.rows;int img_w = input_mat.cols;input_mat.convertTo(input_mat, CV_32FC3, 1.0/255);// 将图片写入有向无环图graph输入边input.set(input_mat);// 定义有向无环图graph的输出结果cv::Mat result(img_h, img_w, CV_32FC3);//model::DetectResult result;// 将输出结果写入有向无环图graph输出边output.set(result);// 有向无环图Graphz运行NNDEPLOY_TIME_POINT_START("graph->run()");status = graph->run();if (status != base::kStatusCodeOk) {NNDEPLOY_LOGE("graph run failed");return -1;}NNDEPLOY_TIME_POINT_END("graph->run()");//drawBox(input_mat, result);std::string ouput_path = demo::getOutputPath();result.convertTo(result, CV_8UC3, 255);//cv::imwrite("ret.png", output);cv::imwrite(ouput_path, result);// 有向无环图graphz反初始化NNDEPLOY_TIME_POINT_START("graph->deinit()");status = graph->deinit();if (status != base::kStatusCodeOk) {NNDEPLOY_LOGE("graph deinit failed");return -1;}NNDEPLOY_TIME_POINT_END("graph->deinit()");NNDEPLOY_TIME_PROFILER_PRINT("detetct time profiler");// 有向无环图graphz销毁delete graph;NNDEPLOY_LOGE("hello world!\n");return 0;
}

3. 修改 graph

一个完整的graph包括:

  1. 前处理需要完成 从 h,w,c foat32 -> c, h, w float32
    2.然后infer跑model;:输入输出都是 c,h,w, 0-1, float32
    3.那么后处理需要完成 从 c, h, w,float32 -> h, w, c, float32

dag::Graph* createYoloV5Graph(const std::string& name,
base::InferenceType inference_type,
base::DeviceType device_type, dag::Edge* input,
dag::Edge* output, base::ModelType model_type,
bool is_path,
std::vectorstd::string model_value)
中修改前后处理函数即可。

前处理,infer , 后处理是一个 graph , 也就是demo中完整的图。
demo中的input和output是 完整的图的输入输出。

然后前处理,infer, 后处理 内部也有自己的input和output,不要搞混淆了。

比如模型infer输入,输出都是c,h,w, float32的结果,
后处理 input是 c,h,w float32 的数据,output转换为 h,w,c float32的数据(对应上面的cv::Mat result(img_h, img_w, CV_32FC3);)

那么我们修改 后处理函数为

base::Status YoloPostProcess::runV5V6() {// data, img_data 就是输入和输出的指针,将图像从c,h,w转为h,w,c device::Tensor* tensor = inputs_[0]->getTensor();float* data = (float*)tensor->getPtr();int batch = tensor->getBatch();int channel = tensor->getChannel();int height = tensor->getHeight();int width = tensor->getWidth();
NNDEPLOY_LOGE("batch:%d, channel:%d, height:%d, width:%d. (%f,%f,%f))\n", batch,  channel, height, width, data[0], data[1], data[2]);
cv::Mat* dst = outputs_[0]->getCvMat();
NNDEPLOY_LOGE("mat  channel:%d, height:%d, width:%d.\n", dst->channels(),   dst->rows, dst->cols);auto* img_data = (float*)dst->data;for (int h = 0; h < height; h++){for (int w = 0; w < width; w++){for (int c = 0; c < 3; c++){int in_index = h * width * 3 + w * 3 + c;int out_index = c * width * height + h * width + w;// if (w < 10)//   if(h < 10)//     printf("%.2f,", data[out_index]);img_data[in_index] = data[out_index];}}// if(h < 10)//   printf("\n");}return base::kStatusCodeOk;
}

前处理也是同样的道理。

4. 总结

前后处理都完成后,进重新编译,得到的./install/lib/demo_nndeploy_detect 就是处理 UNET类型的输入输出了, 不能处理目标检测网络了,目标检测的输入是 uint8 image, 输出的是一系列目标框,对应的前后处理都是不同的。
1080P的图像, 在我训练的降噪model(未量化)上 基于openvino在 amd的Ryzen Embedded上可以跑到30-60ms。
降噪前后对比:降噪最重要是不损失细节且可以提升清晰度。
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

相关文章:

部署系列六基于nndeploy的深度学习 图像降噪unet部署

文章目录 1.直接在源代码demo中修改2. 如何修改呢&#xff1f;3. 修改 graph4. 总结 https://github.com/DeployAI/nndeploy https://nndeploy-zh.readthedocs.io/zh/latest/introduction/index.html 通过以上2个官方链接对nndeploy基本的使用方法应该有所了解了。 下面就是利用…...

使用 ClickHouse 做日志分析

原作&#xff1a;Monika Singh & Pradeep Chhetri 这是我们在 Monitorama 2022 上发表的演讲的改编稿。您可以在此处找到包含演讲者笔记的幻灯片和此处的视频。 当 Cloudflare 的请求抛出错误时&#xff0c;信息会记录在我们的 requests_error 管道中。错误日志用于帮助解…...

华为ospf路由协议防环和次优路径中一些难点问题分析

第一种情况是ar3的/0/0/2口和ar4的0/0/2口发布在区域1时&#xff0c;当ar1连接ar2的线断了以后&#xff0c;骨干区域就断了&#xff0c;1.1.1.1到2.2.2.2就断了&#xff0c;ping不通了。但ar5和ar6可以ping通2.2.2.2和1.1.1.1&#xff0c;ar3和ar4不可以ping通2.2.2.2和1.1.1.1…...

python-opencv划痕检测-续

python-opencv划痕检测-续 这次划痕检测&#xff0c;是上一次划痕检测的续集。 处理的图像如下&#xff1a; 这次划痕检测&#xff0c;我们经过如下几步: 第一步&#xff1a;读取灰度图像 第二步&#xff1a;进行均值滤波 第三步&#xff1a;进行图像差分 第四步&#xff1…...

c++[string实现、反思]

我的码云 我的string码云 分析总结 1.项目结构 所有的类和函数需要在namespace中实现&#xff0c;要和string高度对应 private:char* _str;//字符串size_t _size;//有效长度size_t _capacity;//总空间&#xff0c;包括\0const static size_t npos-1;2.定义变量 <1> 所…...

c++版本opencv计算灰度图像的轮廓点

代码 #include<iostream> #include<opencv.hpp>int main() {std::string imgPath("D:\\prostate_run\\result_US_20230804_141531\\mask\\us\\104.bmp");cv::Mat imgGray cv::imread(imgPath, 0);cv::Mat kernel cv::getStructuringElement(cv::MORPH…...

【05】ES6:函数的扩展

一、函数参数的默认值 ES6 允许为函数的参数设置默认值&#xff0c;即直接写在参数定义的后面。 1、基本用法 默认值的生效条件 不传参数&#xff0c;或者明确的传递 undefined 作为参数&#xff0c;只有这两种情况下&#xff0c;默认值才会生效。 注意&#xff1a;null 就…...

Ubuntu20.04安装搜狗输入法

1、安装包下载 搜狗输入法linux-首页搜狗输入法for linux—支持全拼、简拼、模糊音、云输入、皮肤、中英混输https://shurufa.sogou.com/linux点击立即下载&#xff0c;根据自己的硬件选择deb安装包。 2、输入法安装 当第一步完成以后&#xff0c;页面会自动跳转至搜狗的安装…...

linux的基础命令

文章目录 linux的基础命令一、linux的目录结构&#xff08;一&#xff09;Linux路径的描述方式 二、Linux命令入门&#xff08;一&#xff09;Linux命令基础格式 三、ls命令&#xff08;一&#xff09;HOME目录和工作目录&#xff08;二&#xff09;ls命令的参数1.ls命令的-a选…...

linux查询某个进程使用的内存量

linux查询某个进程使用的内存量 查进程用的内存&#xff0c;查看进程占用的内存量&#xff0c;centos查询内存使用 查某个进程id使用的内存量 ps -p 24450 -o rss | awk {print int($1/1024)"MB"} 该命令的含义是&#xff1a; ps -p 24450: 查找进程ID为24450的进…...

list的总结

目录 1.什么是list 1.1list 的优势和劣势 优势&#xff1a; 劣势&#xff1a; 2.构造函数 2.1 default (1) 2.2 fill (2) 2.3 range (3) 2.4 copy (4) 3.list iterator的使用 3.1. begin() 3.2. end() 3.3迭代器遍历 4. list容量函数 4.1. empty() 4.2. siz…...

c语言数字转圈

数字转圈 题干输入整数 N&#xff08;1≤N≤9&#xff09;&#xff0c;输出如下 N 阶方阵。 若输入5显示如下方阵&#xff1a; * 1** 2** 3** 4** 5* *16**17**18**19** 6* *15**24**25**20** 7* *14**23**22**21** 8* *13**12**11**10** 9*输入样例3输出样例* 1*…...

Apache Superset数据分析平台如何实现公网实时远程访问数据【内网穿透】

文章目录 前言1. 使用Docker部署Apache Superset1.1 第一步安装docker 、docker compose1.2 克隆superset代码到本地并使用docker compose启动 2. 安装cpolar内网穿透&#xff0c;实现公网访问3. 设置固定连接公网地址 前言 Superset是一款由中国知名科技公司开源的“现代化的…...

HarmonyOS应用开发实战—登录页面【ArkTS】

文章目录 本页面实战效果预览图一.HarmonyOS应用开发1.1HarmonyOS 详解1.2 ArkTS详解二.HarmonyOS应用开发实战—登录页面【ArkTS】2.1 ArkTS页面源码2.2 代码解析2.3 心得本页面实战效果预览图 一.HarmonyOS应用开发 1.1HarmonyOS 详解 HarmonyOS(鸿蒙操作系统)是华为公司…...

@RequestMapping

目录 作用&#xff1a; 位置&#xff1a; 属性 1.value 2.method 3.params 4.header 作用&#xff1a; 该注解是一个用来处理请求地址映射的注解。 位置&#xff1a; 可用于映射一个请求或一个方法&#xff0c;可以用在类或方法上。 用于方法上&#xff0c;表示在类的…...

操作系统 应用题 例题+参考答案(考研真题)

1.&#xff08;考研真题&#xff09;一个多道批处理系统中仅有P1和P2两个作业&#xff0c;P2比P1晚5ms到达&#xff0c;它们的计算和I/O操作顺序如下。 P1&#xff1a;计算60ms&#xff0c;I/O 80ms&#xff0c;计算20ms。 P2&#xff1a;计算120ms&#xff0c;I/O 40ms&…...

免费获取GPT-4的五种工具

不可否认&#xff0c;由OpenAI带来的GPT-4已是全球最受欢迎的、功能最强大的大语言模型&#xff08;LLM&#xff09;之一。大多数人都需要使用ChatGPT Plus的订阅服务去访问GPT-4。为此&#xff0c;他们通常需要每月支付20美元。那么问题来了&#xff0c;如果您不想每月有这笔支…...

XTU OJ 1146 矩阵乘法学习笔记

原题 题目描述 给你两个矩阵A(n*k),B(k*m),请求A*B。 输入 第一行是一个整数K&#xff0c;表示样例的个数。 每个样例包含两个矩阵A和B。 每个矩阵的第一行是两个整数n,m,(1≤n,m≤10)表示矩阵的行和列 以后的n行&#xff0c;每行m个整数&#xff0c;每个整数的绝对值不超过…...

基于官方YOLOv4开发构建目标检测模型超详细实战教程【以自建缺陷检测数据集为例】

本文是关于基于YOLOv4开发构建目标检测模型的超详细实战教程&#xff0c;超详细实战教程相关的博文在前文有相应的系列&#xff0c;感兴趣的话可以自行移步阅读即可&#xff1a;《基于yolov7开发实践实例分割模型超详细教程》 《YOLOv7基于自己的数据集从零构建模型完整训练、…...

1、Docker概述与安装

相关资源网站&#xff1a; ● docker官网&#xff1a;http://www.docker.com ● Docker Hub仓库官网: https://hub.docker.com/ 注意&#xff0c;如果只是想看Docker的安装&#xff0c;可以直接往下拉跳转到Docker架构与安装章节下的Docker具体安装步骤&#xff0c;一步步带你安…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

django filter 统计数量 按属性去重

在Django中&#xff0c;如果你想要根据某个属性对查询集进行去重并统计数量&#xff0c;你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求&#xff1a; 方法1&#xff1a;使用annotate()和Count 假设你有一个模型Item&#xff0c;并且你想…...

在四层代理中还原真实客户端ngx_stream_realip_module

一、模块原理与价值 PROXY Protocol 回溯 第三方负载均衡&#xff08;如 HAProxy、AWS NLB、阿里 SLB&#xff09;发起上游连接时&#xff0c;将真实客户端 IP/Port 写入 PROXY Protocol v1/v2 头。Stream 层接收到头部后&#xff0c;ngx_stream_realip_module 从中提取原始信息…...

OkHttp 中实现断点续传 demo

在 OkHttp 中实现断点续传主要通过以下步骤完成&#xff0c;核心是利用 HTTP 协议的 Range 请求头指定下载范围&#xff1a; 实现原理 Range 请求头&#xff1a;向服务器请求文件的特定字节范围&#xff08;如 Range: bytes1024-&#xff09; 本地文件记录&#xff1a;保存已…...

什么是EULA和DPA

文章目录 EULA&#xff08;End User License Agreement&#xff09;DPA&#xff08;Data Protection Agreement&#xff09;一、定义与背景二、核心内容三、法律效力与责任四、实际应用与意义 EULA&#xff08;End User License Agreement&#xff09; 定义&#xff1a; EULA即…...

ip子接口配置及删除

配置永久生效的子接口&#xff0c;2个IP 都可以登录你这一台服务器。重启不失效。 永久的 [应用] vi /etc/sysconfig/network-scripts/ifcfg-eth0修改文件内内容 TYPE"Ethernet" BOOTPROTO"none" NAME"eth0" DEVICE"eth0" ONBOOT&q…...

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

20个超级好用的 CSS 动画库

分享 20 个最佳 CSS 动画库。 它们中的大多数将生成纯 CSS 代码&#xff0c;而不需要任何外部库。 1.Animate.css 一个开箱即用型的跨浏览器动画库&#xff0c;可供你在项目中使用。 2.Magic Animations CSS3 一组简单的动画&#xff0c;可以包含在你的网页或应用项目中。 3.An…...

MinIO Docker 部署:仅开放一个端口

MinIO Docker 部署:仅开放一个端口 在实际的服务器部署中,出于安全和管理的考虑,我们可能只能开放一个端口。MinIO 是一个高性能的对象存储服务,支持 Docker 部署,但默认情况下它需要两个端口:一个是 API 端口(用于存储和访问数据),另一个是控制台端口(用于管理界面…...

十九、【用户管理与权限 - 篇一】后端基础:用户列表与角色模型的初步构建

【用户管理与权限 - 篇一】后端基础:用户列表与角色模型的初步构建 前言准备工作第一部分:回顾 Django 内置的 `User` 模型第二部分:设计并创建 `Role` 和 `UserProfile` 模型第三部分:创建 Serializers第四部分:创建 ViewSets第五部分:注册 API 路由第六部分:后端初步测…...