maixcam如何无脑运行运行别人的模型(以安全帽模型为例)
本文章主要讲如何部署上传的模型文件,以及如果你要把你模型按照该流程应该怎么修改,你可以通过该文章得到你想要的应该,该应用也包含的退出按钮,是屏幕退出按钮,因为屏幕退出方便,所以我引用了sipeed的退出图片,之前的应用没设置退出,非常感谢Neucrack 大佬在群中发的有关触摸屏的使用,自己也参考了api文档,直接上干货!!!
如何去使用别人模型应用(我以我的模型为例子)
安装模型应用
扫码安装(方式1)
https://maixhub.com/app 网址上目前应该上传的模型应用不多,目前镜像的话还不支持在线下载,后续应该会支持

maixvision软件安装模型应用到maixcam(方式2,目前博主是ok的)
(1)下载并解压模型
例如下载本博客的附件maix-hat_detect-v3.0.0.zip 并解压
可以得到下面一些文件


(2)安装模型
打开maixvison然后打开上述解压的文件夹


选择应用文件,然后全部勾选点击打包,并安装应用




断开连接,运行应用

点击左上角可以退出应用,后面讲解如何修改为自己的

删除应用可以点击app store,卸载应用

视频演示链接:
https://www.bilibili.com/video/BV1YZ421n7ui/?spm_id_from=333.999.0.0
该模型整个的压缩包在该文件附件中
如何修改为自己的模型应用
从主函数代码可以看到我导入了sipeed退出图片,使用了ts.read() 去读取触摸坐标,再次感谢Neucrack 大佬,具体细节可以看api文档,主要就是ts.read() 返回一个list,如[0,0,0],其中前两个为x,y坐标,第三个是否触摸状态,触摸了就为1。
博主自己的代码
from maix import camera, display, image, nn, app,time,touchscreen
detector = nn.YOLOv5(model="./yolov5s_hat.mud")
cam = camera.Camera(detector.input_width(), detector.input_height(), detector.input_format())
dis = display.Display()
ts = touchscreen.TouchScreen()
stop_app_img = image.load("./ret.png")
while not app.need_exit():
img = cam.read()
img.draw_image(0, 0, stop_app_img)
state = ts.read()
if state[2]==1:
if(state[0]>0 and state[0]<60)and(state[1]>0 and state[1]<60):
print(123)
app.set_exit_flag(True)
objs = detector.detect(img, conf_th = 0.5, iou_th = 0.45)
for obj in objs:
img.draw_rect(obj.x, obj.y, obj.w, obj.h, color = image.COLOR_RED)
msg = f'{detector.labels[obj.class_id]}: {obj.score:.2f}'
img.draw_string(obj.x, obj.y, msg, color = image.COLOR_RED)
dis.show(img)
修改你自己的模型只需要替换mud 文件以及cvmodel 文件,以及记得把这些文件放置到同级目录下,不然找不到路径!!!
感谢
感谢Neucrack 大佬
|