0
点赞
收藏
分享

微信扫一扫

m基于深度学习的肉类新鲜度检测系统matlab仿真,带GUI操作界面

yundejia 04-04 22:45 阅读 2

1.算法仿真效果 matlab2022a仿真结果如下: 1.jpeg2.jpeg3.jpeg5.jpeg6.jpeg7.jpeg4.jpeg

2.算法涉及理论知识概要 数据采集:获取肉类样品在不同新鲜度阶段的图像数据,通常使用高分辨率相机拍摄并标注对应的新鲜度等级。

  GoogleNet模型因其独特的“ inception ”模块而得名,这种模块设计旨在同时利用不同尺度的特征。传统的卷积层在同一层面上使用固定大小的滤波器,而Inception模块则在一个模块内部集成多种大小的卷积核以捕获多尺度信息。

Inception模块 一个基本的Inception模块可以包括1x1、3x3和5x5卷积层,以及一个最大池化层,所有层的输出都会进行线性组合。例如,对于一个通道数为c 的输入特征图,其经过1x1卷积层(用于减少计算量和维度),3x3和5x5卷积层进行特征提取,以及最大池化层后,各层输出分别记作 a,b,c,d,尺寸分别为′a′,b′,c′,d′,则总输出O 可以表示为:

8.png

GoogLeNet模型结构 整个GoogLeNet模型由一系列堆叠的Inception模块构成,还包括了辅助分类器以增强梯度传播和模型训练。每一层都有批量归一化(Batch Normalization)和ReLU激活函数进行非线性变换。

肉类新鲜度检测应用 在应用于肉类新鲜度检测时,首先将肉类图像输入到GoogLeNet模型中,通过多个层级的特征提取,模型最终会在顶层生成一个表示新鲜度等级的概率分布。假设我们有 K 类新鲜度级别,则输出层通过softmax函数给出各个级别的概率:

9.png

训练过程 模型的训练目标是最小化交叉熵损失函数:

10.png

3.MATLAB核心程序

maxEpochs = NEpochs;
Minibatch_Size = NMB;
Validation_Frequency = floor(numel(Resized_Training_Dataset.Files)/Minibatch_Size);
Training_Options = trainingOptions('sgdm', ...
    'MiniBatchSize', Minibatch_Size, ...
    'MaxEpochs', maxEpochs, ...
    'InitialLearnRate', LR, ...
    'Shuffle', 'every-epoch', ...
    'ValidationData', Resized_Validation_Dataset, ...
    'ValidationFrequency', Validation_Frequency, ...
    'Verbose', false, ...
    'Plots', 'training-progress');
 
% 使用训练选项训练网络
net = trainNetwork(Resized_Training_Dataset, New_Network, Training_Options);
% 保存训练后的网络
save gnet.mat net
 
 
 
 
function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double
 
 
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
 
 
function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double
 
 
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
 
 
function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(hObject,'String') returns contents of edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double
 
 
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
 
 
function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(hObject,'String') returns contents of edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double
 
 
% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
 
 
function edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(hObject,'String') returns contents of edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double
 
 
% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

举报

相关推荐

0 条评论