
python技巧
HHXC浩瀚星辰
每天进步一点点
展开
-
深入浅出Lambda函数:Python中的匿名函数与实用案例
Lambda函数是Python中的匿名函数,也被称为内联函数或一次性函数。它们的定义方式与普通函数不同,更简洁,更适用于简单的操作。Lambda函数通常用于临时需求的函数,或在高阶函数中作为参数传递。一般函数定义及调用30 12lambda函数定义及调用30 12。原创 2024-04-24 14:38:36 · 465 阅读 · 0 评论 -
教你用Cython加密Python代码
自己编写的代码,发给别人执行时,不要让别人看到核心代码,这就需要一个工具将主要模块代码进行加密,然而对于Python来说,并没有像MATLAB那种的p代码,很麻烦。这里是支持Python3.8和3.7两个版本的pyd文件。原创 2024-04-20 19:52:40 · 735 阅读 · 0 评论 -
用imgaug进行图像扩充
#!usr/bin/python# -*- coding: utf-8 -*-import cv2from imgaug import augmenters as iaaimport os# Sometimes(0.5, ...) applies the given augmenter in 50% of all cases,# e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second image.some.原创 2021-09-19 10:28:48 · 375 阅读 · 0 评论 -
教你计算Pytorch模型的计算量(FLOPs)和参数量(Params)
计算量对应时间复杂度(时间的长短),参数量对应空间复杂度(占用显存大小)1GFPLOs = 10^9FLOPs即:10亿次浮点运算方法一1、安装模块pip install thop2、计算import torchimport torchvisionfrom thop import profile# Modelprint('==> Building model..')model = torchvision.models.alexnet(pretrained=.原创 2021-08-31 23:03:01 · 5117 阅读 · 0 评论 -
教你将视频指定帧数间隔保存为图像&opencv-python
安装好python ,配置好opencv-python# 导入所有必要的库import cv2import os# 从指定的路径读取视频cam = cv2.VideoCapture("F:/video1.mp4")try: # 创建名为data的文件夹 if not os.path.exists('data'): os.makedirs('data')# 如果未创建,则引发错误except OSError: print('Error: Crea原创 2021-04-27 16:49:57 · 2217 阅读 · 16 评论