Compare commits
21 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0d9222dd7e | 11 months ago |
|
|
0bfe81da12 | 11 months ago |
|
|
844104b3ef | 11 months ago |
|
|
22e2838843 | 11 months ago |
|
|
4b8d0732a6 | 11 months ago |
|
|
1db9be8367 | 11 months ago |
|
|
776a1b8ce0 | 11 months ago |
|
|
6048141bd4 | 11 months ago |
|
|
e0bf3559fc | 11 months ago |
|
|
cdc17350db | 11 months ago |
|
|
73017258ed | 11 months ago |
|
|
a676058385 | 11 months ago |
|
|
1bc9e6f732 | 11 months ago |
|
|
0d6892df17 | 11 months ago |
|
|
7ff37fcee5 | 11 months ago |
|
|
8add84ec2e | 11 months ago |
|
|
2c1ee5a305 | 11 months ago |
|
|
d2f2568b16 | 11 months ago |
|
|
839b976075 | 11 months ago |
|
|
91ac072e60 | 11 months ago |
|
|
5cfa22e4d3 | 11 months ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,135 +0,0 @@
|
||||
#include "FFVideoFormatConvert.h"
|
||||
#include "VideoObjNetwork.h"
|
||||
|
||||
CFFVideoFormatConvert::CFFVideoFormatConvert(void)
|
||||
: m_img_convert_ctx(NULL)
|
||||
, m_pFrame(NULL)
|
||||
, m_pBuffer(NULL), m_uBufferSize(0)
|
||||
, m_iWidth(0), m_iHeight(0)
|
||||
, m_pImage(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CFFVideoFormatConvert::~CFFVideoFormatConvert(void)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void CFFVideoFormatConvert::Close()
|
||||
{
|
||||
if (m_img_convert_ctx)
|
||||
{
|
||||
sws_freeContext(m_img_convert_ctx);
|
||||
m_img_convert_ctx = NULL;
|
||||
}
|
||||
|
||||
if (m_pFrame)
|
||||
{
|
||||
av_frame_free(&m_pFrame);
|
||||
m_pFrame = NULL;
|
||||
}
|
||||
|
||||
if (m_pBuffer)
|
||||
{
|
||||
av_free(m_pBuffer);
|
||||
m_pBuffer = NULL;
|
||||
m_uBufferSize = 0;
|
||||
}
|
||||
|
||||
if (m_pImage != NULL)
|
||||
{
|
||||
delete m_pImage;
|
||||
m_pImage = NULL;
|
||||
}
|
||||
|
||||
m_iWidth = 0;
|
||||
m_iHeight = 0;
|
||||
}
|
||||
|
||||
bool CFFVideoFormatConvert::RGB32toYUV420P(const QImage* pIn, AVFrame** pOut)
|
||||
{
|
||||
// reinitialize object if image width or height changed
|
||||
if (pIn->width() != m_iWidth || pIn->height() != m_iHeight)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_iWidth = pIn->width();
|
||||
m_iHeight = pIn->height();
|
||||
m_uBufferSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pIn->width(), pIn->height(), 1);
|
||||
m_pBuffer = (uint8_t *) av_malloc(m_uBufferSize);
|
||||
}
|
||||
|
||||
if (m_pFrame == NULL)
|
||||
{
|
||||
m_pFrame = av_frame_alloc();
|
||||
m_pFrame->width = pIn->width();
|
||||
m_pFrame->height = pIn->height();
|
||||
av_image_fill_arrays(m_pFrame->data, m_pFrame->linesize,
|
||||
m_pBuffer, AV_PIX_FMT_YUV420P, pIn->width(), pIn->height(), 1);
|
||||
}
|
||||
|
||||
if (m_img_convert_ctx == NULL)
|
||||
{
|
||||
m_img_convert_ctx = sws_getContext(pIn->width(), pIn->height(),
|
||||
AV_PIX_FMT_RGB32,
|
||||
pIn->width(), pIn->height(),
|
||||
AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
const uint8_t *const srcSlice[] = { pIn->bits() };
|
||||
const int srcStride[] = { pIn->bytesPerLine()};
|
||||
sws_scale(m_img_convert_ctx,
|
||||
srcSlice,
|
||||
srcStride, 0, pIn->height(),
|
||||
m_pFrame->data,
|
||||
m_pFrame->linesize);
|
||||
|
||||
*pOut = m_pFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFFVideoFormatConvert::YUV420P2RGB32(const AVFrame* pIn, QImage** pOut)
|
||||
{
|
||||
// reinitialize object if image width or height changed
|
||||
if (pIn->width != m_iWidth || pIn->height != m_iHeight)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_iWidth = pIn->width;
|
||||
m_iHeight = pIn->height;
|
||||
m_uBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB32, pIn->width, pIn->height, 1);
|
||||
m_pBuffer = (uint8_t *)av_malloc(m_uBufferSize);
|
||||
}
|
||||
|
||||
if (m_pFrame == NULL)
|
||||
{
|
||||
m_pFrame = av_frame_alloc();
|
||||
av_image_fill_arrays(m_pFrame->data, m_pFrame->linesize,
|
||||
m_pBuffer, AV_PIX_FMT_RGB32, pIn->width, pIn->height, 1);
|
||||
}
|
||||
|
||||
if (m_img_convert_ctx == NULL)
|
||||
{
|
||||
m_img_convert_ctx = sws_getContext(pIn->width, pIn->height,
|
||||
AV_PIX_FMT_YUV420P,
|
||||
pIn->width, pIn->height,
|
||||
AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
sws_scale(m_img_convert_ctx,
|
||||
(uint8_t const * const *)pIn->data,
|
||||
pIn->linesize, 0, pIn->height,
|
||||
m_pFrame->data,
|
||||
m_pFrame->linesize);
|
||||
|
||||
*pOut = new QImage((uchar *)m_pFrame->data[0], m_iWidth, m_iHeight, QImage::Format_RGB32);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include <QImage>
|
||||
|
||||
struct AVFrame;
|
||||
struct SwsContext;
|
||||
|
||||
class CFFVideoFormatConvert
|
||||
{
|
||||
public:
|
||||
CFFVideoFormatConvert(void);
|
||||
~CFFVideoFormatConvert(void);
|
||||
|
||||
bool RGB32toYUV420P(const QImage* pIn, AVFrame** pOut);
|
||||
bool YUV420P2RGB32(const AVFrame* pIn, QImage** pOut);
|
||||
private:
|
||||
void Close();
|
||||
private:
|
||||
SwsContext* m_img_convert_ctx;
|
||||
AVFrame* m_pFrame;
|
||||
|
||||
uint8_t* m_pBuffer;
|
||||
uint m_uBufferSize;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
QImage* m_pImage;
|
||||
};
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
#ifndef QTCAMERACAPTURE_H
|
||||
#define QTCAMERACAPTURE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QDebug>
|
||||
|
||||
class QtCameraCapture : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PixelFormat {
|
||||
Format_Invalid,
|
||||
Format_ARGB32,
|
||||
Format_ARGB32_Premultiplied,
|
||||
Format_RGB32,
|
||||
Format_RGB24,
|
||||
Format_RGB565,
|
||||
Format_RGB555,
|
||||
Format_ARGB8565_Premultiplied,
|
||||
Format_BGRA32,
|
||||
Format_BGRA32_Premultiplied,
|
||||
Format_BGR32,
|
||||
Format_BGR24,
|
||||
Format_BGR565,
|
||||
Format_BGR555,
|
||||
Format_BGRA5658_Premultiplied,
|
||||
|
||||
Format_AYUV444,
|
||||
Format_AYUV444_Premultiplied,
|
||||
Format_YUV444,
|
||||
Format_YUV420P,
|
||||
Format_YV12,
|
||||
Format_UYVY,
|
||||
Format_YUYV,
|
||||
Format_NV12,
|
||||
Format_NV21,
|
||||
Format_IMC1,
|
||||
Format_IMC2,
|
||||
Format_IMC3,
|
||||
Format_IMC4,
|
||||
Format_Y8,
|
||||
Format_Y16,
|
||||
|
||||
Format_Jpeg,
|
||||
|
||||
Format_CameraRaw,
|
||||
Format_AdobeDng,
|
||||
|
||||
#ifndef Q_QDOC
|
||||
NPixelFormats,
|
||||
#endif
|
||||
Format_User = 1000
|
||||
};
|
||||
|
||||
Q_ENUM(PixelFormat)
|
||||
|
||||
explicit QtCameraCapture(QObject *parent = 0);
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
|
||||
|
||||
bool present(const QVideoFrame &frame) override;
|
||||
|
||||
signals:
|
||||
void frameAvailable(QImage frame);
|
||||
|
||||
};
|
||||
|
||||
#endif // QTCAMERACAPTURE_H
|
||||
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#define GET_STR(x) #x
|
||||
#define A_VER 3
|
||||
#define T_VER 4
|
||||
|
||||
// vertex shader
|
||||
const char *vString = GET_STR(
|
||||
attribute vec4 vertexIn;
|
||||
attribute vec2 textureIn;
|
||||
varying vec2 textureOut;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = vertexIn;
|
||||
textureOut = textureIn;
|
||||
}
|
||||
);
|
||||
|
||||
// texture shader
|
||||
const char *tString = GET_STR(
|
||||
varying vec2 textureOut;
|
||||
uniform sampler2D tex_y;
|
||||
uniform sampler2D tex_u;
|
||||
uniform sampler2D tex_v;
|
||||
void main(void)
|
||||
{
|
||||
vec3 yuv;
|
||||
vec3 rgb;
|
||||
yuv.x = texture2D(tex_y, textureOut).r;
|
||||
yuv.y = texture2D(tex_u, textureOut).r - 0.5;
|
||||
yuv.z = texture2D(tex_v, textureOut).r - 0.5;
|
||||
rgb = mat3(1.0, 1.0, 1.0,
|
||||
0.0, -0.39465, 2.03211,
|
||||
1.13983, -0.58060, 0.0) * yuv;
|
||||
gl_FragColor = vec4(rgb, 1.0);
|
||||
}
|
||||
);
|
||||
@ -1,66 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libswscale/swscale.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
};
|
||||
|
||||
typedef void (*VideoDataCallback)(int iEncode, int iWidth, int iHeight, const char* pData, long lLen, long lPTS, void* pUserParam);
|
||||
|
||||
class VLKVideoWidget;
|
||||
class CVideoObjNetwork
|
||||
{
|
||||
public:
|
||||
CVideoObjNetwork();
|
||||
virtual ~CVideoObjNetwork();
|
||||
|
||||
virtual bool Open(const std::string& strURL, VLKVideoWidget* pVideoWidget);
|
||||
virtual bool IsOpen();
|
||||
void SetDataCallback(VideoDataCallback pVideoDataCB, long lUserParam);
|
||||
virtual void Clear();
|
||||
virtual void Close();
|
||||
virtual bool StartLocalRecord();
|
||||
virtual void StopLocalRecord();
|
||||
virtual void Capture();
|
||||
private:
|
||||
static void ThreadFunc(CVideoObjNetwork* pThis);
|
||||
virtual void OnThreadFunc();
|
||||
|
||||
bool OpenDemux(const std::string& strURL);
|
||||
void CloseDemux();
|
||||
void WriteLocalRecord(const AVPacket* pkt);
|
||||
static int interrupt_callback(void* para);
|
||||
void ReadPacketLoop();
|
||||
|
||||
bool OpenDecoder(const AVCodecParameters *para);
|
||||
void Send2Decode(const AVPacket* pkt);
|
||||
void Send2Display(const AVFrame* frame);
|
||||
void CloseDecoder();
|
||||
private:
|
||||
static bool m_bInit;
|
||||
std::mutex m_mutex;
|
||||
std::string m_strURL;
|
||||
VLKVideoWidget* m_pVideoWidget;
|
||||
|
||||
AVFormatContext* m_pAVFmtContext;
|
||||
int m_iVideoStreamIndex;
|
||||
int m_iAudioStreamIndex;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
std::thread* m_pThread;
|
||||
bool m_bExit;
|
||||
|
||||
VideoDataCallback m_cbFunc;
|
||||
long m_lUserParam;
|
||||
|
||||
AVCodecContext* m_pCodecContext;
|
||||
};
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
#ifndef IMAGEPREVIEWDIALOG_H
|
||||
#define IMAGEPREVIEWDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
|
||||
class ImagePreviewDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImagePreviewDialog(const QString &imagePath, QWidget *parent = nullptr);
|
||||
~ImagePreviewDialog();
|
||||
|
||||
private:
|
||||
QLabel *m_imageLabel;
|
||||
QScrollArea *m_scrollArea;
|
||||
QPushButton *m_closeButton;
|
||||
|
||||
void setupUi();
|
||||
void loadImage(const QString &imagePath);
|
||||
};
|
||||
|
||||
#endif // IMAGEPREVIEWDIALOG_H
|
||||
@ -1,28 +0,0 @@
|
||||
#include "widget.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// print SDK Version
|
||||
qDebug() << "ViewLink SDK Version: " << GetSDKVersion();
|
||||
|
||||
// initialize SDK
|
||||
VLK_Init();
|
||||
|
||||
|
||||
Widget w;
|
||||
w.show();
|
||||
|
||||
int ret = a.exec();
|
||||
|
||||
// diconnect all
|
||||
VLK_Disconnect();
|
||||
|
||||
// uninitialize SDK
|
||||
VLK_UnInit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 39c8188929657d71dfecbac4288025765589c300
|
||||
@ -0,0 +1,69 @@
|
||||
# Details
|
||||
|
||||
Date : 2025-06-10 08:55:17
|
||||
|
||||
Directory e:\\pycharm_projects\\AudioClassification-Pytorch-master
|
||||
|
||||
Total : 54 files, 6851 codes, 838 comments, 1201 blanks, all 8890 lines
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
| [README.md](/README.md) | Markdown | 302 | 0 | 72 | 374 |
|
||||
| [README\_en.md](/README_en.md) | Markdown | 231 | 0 | 45 | 276 |
|
||||
| [audio-classification-platform/README.md](/audio-classification-platform/README.md) | Markdown | 96 | 0 | 41 | 137 |
|
||||
| [audio-classification-platform/backend/app.py](/audio-classification-platform/backend/app.py) | Python | 255 | 35 | 61 | 351 |
|
||||
| [audio-classification-platform/backend/config.py](/audio-classification-platform/backend/config.py) | Python | 22 | 8 | 10 | 40 |
|
||||
| [audio-classification-platform/backend/requirements.txt](/audio-classification-platform/backend/requirements.txt) | pip requirements | 7 | 0 | 1 | 8 |
|
||||
| [audio-classification-platform/frontend/index.html](/audio-classification-platform/frontend/index.html) | HTML | 25 | 0 | 2 | 27 |
|
||||
| [audio-classification-platform/frontend/package.json](/audio-classification-platform/frontend/package.json) | JSON | 24 | 0 | 1 | 25 |
|
||||
| [audio-classification-platform/frontend/src/App.vue](/audio-classification-platform/frontend/src/App.vue) | Vue | 88 | 5 | 14 | 107 |
|
||||
| [audio-classification-platform/frontend/src/components/AudioRecorder.vue](/audio-classification-platform/frontend/src/components/AudioRecorder.vue) | Vue | 551 | 38 | 102 | 691 |
|
||||
| [audio-classification-platform/frontend/src/components/AudioRecorder\_new.vue](/audio-classification-platform/frontend/src/components/AudioRecorder_new.vue) | Vue | 811 | 48 | 162 | 1,021 |
|
||||
| [audio-classification-platform/frontend/src/components/AudioUpload.vue](/audio-classification-platform/frontend/src/components/AudioUpload.vue) | Vue | 580 | 28 | 107 | 715 |
|
||||
| [audio-classification-platform/frontend/src/components/HistoryList.vue](/audio-classification-platform/frontend/src/components/HistoryList.vue) | Vue | 513 | 25 | 79 | 617 |
|
||||
| [audio-classification-platform/frontend/src/components/PredictionResult.vue](/audio-classification-platform/frontend/src/components/PredictionResult.vue) | Vue | 803 | 22 | 117 | 942 |
|
||||
| [audio-classification-platform/frontend/src/main.js](/audio-classification-platform/frontend/src/main.js) | JavaScript | 13 | 1 | 5 | 19 |
|
||||
| [audio-classification-platform/frontend/src/router/index.js](/audio-classification-platform/frontend/src/router/index.js) | JavaScript | 14 | 0 | 4 | 18 |
|
||||
| [audio-classification-platform/frontend/src/utils/api.js](/audio-classification-platform/frontend/src/utils/api.js) | JavaScript | 156 | 25 | 33 | 214 |
|
||||
| [audio-classification-platform/frontend/src/views/HomePage.vue](/audio-classification-platform/frontend/src/views/HomePage.vue) | Vue | 692 | 40 | 110 | 842 |
|
||||
| [audio-classification-platform/frontend/vite.config.js](/audio-classification-platform/frontend/vite.config.js) | JavaScript | 32 | 0 | 2 | 34 |
|
||||
| [audio-classification-platform/start.bat](/audio-classification-platform/start.bat) | Batch | 20 | 0 | 5 | 25 |
|
||||
| [audio-classification-platform/start.sh](/audio-classification-platform/start.sh) | Shell Script | 26 | 3 | 8 | 37 |
|
||||
| [configs/augmentation.yml](/configs/augmentation.yml) | YAML | 21 | 21 | 5 | 47 |
|
||||
| [configs/cam++.yml](/configs/cam++.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/ecapa\_tdnn.yml](/configs/ecapa_tdnn.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/eres2net.yml](/configs/eres2net.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/panns.yml](/configs/panns.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/res2net.yml](/configs/res2net.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/resnet\_se.yml](/configs/resnet_se.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [configs/tdnn.yml](/configs/tdnn.yml) | YAML | 43 | 33 | 5 | 81 |
|
||||
| [create\_data.py](/create_data.py) | Python | 75 | 9 | 16 | 100 |
|
||||
| [eval.py](/eval.py) | Python | 20 | 2 | 5 | 27 |
|
||||
| [extract\_features.py](/extract_features.py) | Python | 13 | 2 | 5 | 20 |
|
||||
| [infer.py](/infer.py) | Python | 17 | 1 | 6 | 24 |
|
||||
| [infer\_record.py](/infer_record.py) | Python | 40 | 7 | 12 | 59 |
|
||||
| [macls/\_\_init\_\_.py](/macls/__init__.py) | Python | 1 | 0 | 1 | 2 |
|
||||
| [macls/data\_utils/\_\_init\_\_.py](/macls/data_utils/__init__.py) | Python | 0 | 0 | 1 | 1 |
|
||||
| [macls/data\_utils/collate\_fn.py](/macls/data_utils/collate_fn.py) | Python | 17 | 4 | 3 | 24 |
|
||||
| [macls/data\_utils/featurizer.py](/macls/data_utils/featurizer.py) | Python | 88 | 36 | 9 | 133 |
|
||||
| [macls/data\_utils/reader.py](/macls/data_utils/reader.py) | Python | 114 | 33 | 11 | 158 |
|
||||
| [macls/metric/\_\_init\_\_.py](/macls/metric/__init__.py) | Python | 0 | 0 | 1 | 1 |
|
||||
| [macls/metric/metrics.py](/macls/metric/metrics.py) | Python | 9 | 1 | 3 | 13 |
|
||||
| [macls/optimizer/\_\_init\_\_.py](/macls/optimizer/__init__.py) | Python | 26 | 0 | 7 | 33 |
|
||||
| [macls/optimizer/scheduler.py](/macls/optimizer/scheduler.py) | Python | 42 | 0 | 7 | 49 |
|
||||
| [macls/predict.py](/macls/predict.py) | Python | 124 | 47 | 7 | 178 |
|
||||
| [macls/trainer.py](/macls/trainer.py) | Python | 338 | 99 | 20 | 457 |
|
||||
| [macls/utils/\_\_init\_\_.py](/macls/utils/__init__.py) | Python | 0 | 0 | 1 | 1 |
|
||||
| [macls/utils/checkpoint.py](/macls/utils/checkpoint.py) | Python | 113 | 40 | 10 | 163 |
|
||||
| [macls/utils/record.py](/macls/utils/record.py) | Python | 18 | 8 | 6 | 32 |
|
||||
| [macls/utils/utils.py](/macls/utils/utils.py) | Python | 99 | 16 | 17 | 132 |
|
||||
| [record\_audio.py](/record_audio.py) | Python | 10 | 0 | 5 | 15 |
|
||||
| [requirements.txt](/requirements.txt) | pip requirements | 17 | 0 | 1 | 18 |
|
||||
| [setup.py](/setup.py) | Python | 43 | 1 | 11 | 55 |
|
||||
| [tools/download\_language\_data.sh](/tools/download_language_data.sh) | Shell Script | 19 | 1 | 10 | 30 |
|
||||
| [train.py](/train.py) | Python | 25 | 1 | 5 | 31 |
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
@ -0,0 +1,15 @@
|
||||
# Diff Details
|
||||
|
||||
Date : 2025-06-10 08:55:17
|
||||
|
||||
Directory e:\\pycharm_projects\\AudioClassification-Pytorch-master
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||
|
@ -0,0 +1,19 @@
|
||||
# Diff Summary
|
||||
|
||||
Date : 2025-06-10 08:55:17
|
||||
|
||||
Directory e:\\pycharm_projects\\AudioClassification-Pytorch-master
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||
@ -0,0 +1,22 @@
|
||||
Date : 2025-06-10 08:55:17
|
||||
Directory : e:\pycharm_projects\AudioClassification-Pytorch-master
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
Languages
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| Total | | 0 | 0 | 0 | 0 |
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,50 @@
|
||||
# Summary
|
||||
|
||||
Date : 2025-06-10 08:55:17
|
||||
|
||||
Directory e:\\pycharm_projects\\AudioClassification-Pytorch-master
|
||||
|
||||
Total : 54 files, 6851 codes, 838 comments, 1201 blanks, all 8890 lines
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| Vue | 7 | 4,038 | 206 | 691 | 4,935 |
|
||||
| Python | 25 | 1,509 | 350 | 240 | 2,099 |
|
||||
| Markdown | 3 | 629 | 0 | 158 | 787 |
|
||||
| YAML | 8 | 322 | 252 | 40 | 614 |
|
||||
| JavaScript | 4 | 215 | 26 | 44 | 285 |
|
||||
| Shell Script | 2 | 45 | 4 | 18 | 67 |
|
||||
| HTML | 1 | 25 | 0 | 2 | 27 |
|
||||
| pip requirements | 2 | 24 | 0 | 2 | 26 |
|
||||
| JSON | 1 | 24 | 0 | 1 | 25 |
|
||||
| Batch | 1 | 20 | 0 | 5 | 25 |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| . | 54 | 6,851 | 838 | 1,201 | 8,890 |
|
||||
| . (Files) | 11 | 793 | 23 | 183 | 999 |
|
||||
| audio-classification-platform | 19 | 4,728 | 278 | 864 | 5,870 |
|
||||
| audio-classification-platform (Files) | 3 | 142 | 3 | 54 | 199 |
|
||||
| audio-classification-platform\\backend | 3 | 284 | 43 | 72 | 399 |
|
||||
| audio-classification-platform\\frontend | 13 | 4,302 | 232 | 738 | 5,272 |
|
||||
| audio-classification-platform\\frontend (Files) | 3 | 81 | 0 | 5 | 86 |
|
||||
| audio-classification-platform\\frontend\\src | 10 | 4,221 | 232 | 733 | 5,186 |
|
||||
| audio-classification-platform\\frontend\\src (Files) | 2 | 101 | 6 | 19 | 126 |
|
||||
| audio-classification-platform\\frontend\\src\\components | 5 | 3,258 | 161 | 567 | 3,986 |
|
||||
| audio-classification-platform\\frontend\\src\\router | 1 | 14 | 0 | 4 | 18 |
|
||||
| audio-classification-platform\\frontend\\src\\utils | 1 | 156 | 25 | 33 | 214 |
|
||||
| audio-classification-platform\\frontend\\src\\views | 1 | 692 | 40 | 110 | 842 |
|
||||
| configs | 8 | 322 | 252 | 40 | 614 |
|
||||
| macls | 15 | 989 | 284 | 104 | 1,377 |
|
||||
| macls (Files) | 3 | 463 | 146 | 28 | 637 |
|
||||
| macls\\data_utils | 4 | 219 | 73 | 24 | 316 |
|
||||
| macls\\metric | 2 | 9 | 1 | 4 | 14 |
|
||||
| macls\\optimizer | 2 | 68 | 0 | 14 | 82 |
|
||||
| macls\\utils | 4 | 230 | 64 | 34 | 328 |
|
||||
| tools | 1 | 19 | 1 | 10 | 30 |
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
@ -0,0 +1,107 @@
|
||||
Date : 2025-06-10 08:55:17
|
||||
Directory : e:\pycharm_projects\AudioClassification-Pytorch-master
|
||||
Total : 54 files, 6851 codes, 838 comments, 1201 blanks, all 8890 lines
|
||||
|
||||
Languages
|
||||
+------------------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+------------------+------------+------------+------------+------------+------------+
|
||||
| Vue | 7 | 4,038 | 206 | 691 | 4,935 |
|
||||
| Python | 25 | 1,509 | 350 | 240 | 2,099 |
|
||||
| Markdown | 3 | 629 | 0 | 158 | 787 |
|
||||
| YAML | 8 | 322 | 252 | 40 | 614 |
|
||||
| JavaScript | 4 | 215 | 26 | 44 | 285 |
|
||||
| Shell Script | 2 | 45 | 4 | 18 | 67 |
|
||||
| HTML | 1 | 25 | 0 | 2 | 27 |
|
||||
| pip requirements | 2 | 24 | 0 | 2 | 26 |
|
||||
| JSON | 1 | 24 | 0 | 1 | 25 |
|
||||
| Batch | 1 | 20 | 0 | 5 | 25 |
|
||||
+------------------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| . | 54 | 6,851 | 838 | 1,201 | 8,890 |
|
||||
| . (Files) | 11 | 793 | 23 | 183 | 999 |
|
||||
| audio-classification-platform | 19 | 4,728 | 278 | 864 | 5,870 |
|
||||
| audio-classification-platform (Files) | 3 | 142 | 3 | 54 | 199 |
|
||||
| audio-classification-platform\backend | 3 | 284 | 43 | 72 | 399 |
|
||||
| audio-classification-platform\frontend | 13 | 4,302 | 232 | 738 | 5,272 |
|
||||
| audio-classification-platform\frontend (Files) | 3 | 81 | 0 | 5 | 86 |
|
||||
| audio-classification-platform\frontend\src | 10 | 4,221 | 232 | 733 | 5,186 |
|
||||
| audio-classification-platform\frontend\src (Files) | 2 | 101 | 6 | 19 | 126 |
|
||||
| audio-classification-platform\frontend\src\components | 5 | 3,258 | 161 | 567 | 3,986 |
|
||||
| audio-classification-platform\frontend\src\router | 1 | 14 | 0 | 4 | 18 |
|
||||
| audio-classification-platform\frontend\src\utils | 1 | 156 | 25 | 33 | 214 |
|
||||
| audio-classification-platform\frontend\src\views | 1 | 692 | 40 | 110 | 842 |
|
||||
| configs | 8 | 322 | 252 | 40 | 614 |
|
||||
| macls | 15 | 989 | 284 | 104 | 1,377 |
|
||||
| macls (Files) | 3 | 463 | 146 | 28 | 637 |
|
||||
| macls\data_utils | 4 | 219 | 73 | 24 | 316 |
|
||||
| macls\metric | 2 | 9 | 1 | 4 | 14 |
|
||||
| macls\optimizer | 2 | 68 | 0 | 14 | 82 |
|
||||
| macls\utils | 4 | 230 | 64 | 34 | 328 |
|
||||
| tools | 1 | 19 | 1 | 10 | 30 |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\README.md | Markdown | 302 | 0 | 72 | 374 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\README_en.md | Markdown | 231 | 0 | 45 | 276 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\README.md | Markdown | 96 | 0 | 41 | 137 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\backend\app.py | Python | 255 | 35 | 61 | 351 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\backend\config.py | Python | 22 | 8 | 10 | 40 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\backend\requirements.txt | pip requirements | 7 | 0 | 1 | 8 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\index.html | HTML | 25 | 0 | 2 | 27 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\package.json | JSON | 24 | 0 | 1 | 25 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\App.vue | Vue | 88 | 5 | 14 | 107 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\components\AudioRecorder.vue | Vue | 551 | 38 | 102 | 691 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\components\AudioRecorder_new.vue | Vue | 811 | 48 | 162 | 1,021 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\components\AudioUpload.vue | Vue | 580 | 28 | 107 | 715 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\components\HistoryList.vue | Vue | 513 | 25 | 79 | 617 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\components\PredictionResult.vue | Vue | 803 | 22 | 117 | 942 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\main.js | JavaScript | 13 | 1 | 5 | 19 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\router\index.js | JavaScript | 14 | 0 | 4 | 18 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\utils\api.js | JavaScript | 156 | 25 | 33 | 214 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\src\views\HomePage.vue | Vue | 692 | 40 | 110 | 842 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\frontend\vite.config.js | JavaScript | 32 | 0 | 2 | 34 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\start.bat | Batch | 20 | 0 | 5 | 25 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\audio-classification-platform\start.sh | Shell Script | 26 | 3 | 8 | 37 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\augmentation.yml | YAML | 21 | 21 | 5 | 47 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\cam++.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\ecapa_tdnn.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\eres2net.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\panns.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\res2net.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\resnet_se.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\configs\tdnn.yml | YAML | 43 | 33 | 5 | 81 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\create_data.py | Python | 75 | 9 | 16 | 100 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\eval.py | Python | 20 | 2 | 5 | 27 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\extract_features.py | Python | 13 | 2 | 5 | 20 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\infer.py | Python | 17 | 1 | 6 | 24 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\infer_record.py | Python | 40 | 7 | 12 | 59 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\__init__.py | Python | 1 | 0 | 1 | 2 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\data_utils\__init__.py | Python | 0 | 0 | 1 | 1 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\data_utils\collate_fn.py | Python | 17 | 4 | 3 | 24 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\data_utils\featurizer.py | Python | 88 | 36 | 9 | 133 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\data_utils\reader.py | Python | 114 | 33 | 11 | 158 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\metric\__init__.py | Python | 0 | 0 | 1 | 1 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\metric\metrics.py | Python | 9 | 1 | 3 | 13 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\optimizer\__init__.py | Python | 26 | 0 | 7 | 33 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\optimizer\scheduler.py | Python | 42 | 0 | 7 | 49 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\predict.py | Python | 124 | 47 | 7 | 178 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\trainer.py | Python | 338 | 99 | 20 | 457 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\utils\__init__.py | Python | 0 | 0 | 1 | 1 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\utils\checkpoint.py | Python | 113 | 40 | 10 | 163 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\utils\record.py | Python | 18 | 8 | 6 | 32 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\macls\utils\utils.py | Python | 99 | 16 | 17 | 132 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\record_audio.py | Python | 10 | 0 | 5 | 15 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\requirements.txt | pip requirements | 17 | 0 | 1 | 18 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\setup.py | Python | 43 | 1 | 11 | 55 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\tools\download_language_data.sh | Shell Script | 19 | 1 | 10 | 30 |
|
||||
| e:\pycharm_projects\AudioClassification-Pytorch-master\train.py | Python | 25 | 1 | 5 | 31 |
|
||||
| Total | | 6,851 | 838 | 1,201 | 8,890 |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+
|
||||
@ -0,0 +1,296 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
macls.egg-info/
|
||||
|
||||
# PyInstaller
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django/Flask stuff
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
Pipfile.lock
|
||||
|
||||
# PEP 582
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# Node.js dependencies
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
package-lock.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage/
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env.local
|
||||
.env.production
|
||||
|
||||
# parcel-bundler cache
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
|
||||
# Gatsby files
|
||||
# Comment in the public line in if your project uses Gatsby
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# Audio Classification specific ignores
|
||||
# Model files (usually large)
|
||||
*.pth
|
||||
*.pt
|
||||
*.h5
|
||||
*.ckpt
|
||||
*.pb
|
||||
*.onnx
|
||||
*.pkl
|
||||
*.joblib
|
||||
|
||||
# Dataset directories (usually large audio files)
|
||||
dataset/
|
||||
dataset/*/audio/
|
||||
dataset/*/wav/
|
||||
dataset/*/mp3/
|
||||
dataset/*/flac/
|
||||
# Uncomment if you want to ignore all audio files
|
||||
# *.wav
|
||||
# *.mp3
|
||||
# *.flac
|
||||
# *.ogg
|
||||
# *.m4a
|
||||
# *.aac
|
||||
|
||||
# Training artifacts and logs
|
||||
log/
|
||||
logs/
|
||||
output/
|
||||
outputs/
|
||||
uploads/
|
||||
results/
|
||||
checkpoints/
|
||||
models/
|
||||
pretrained_models/
|
||||
feature_models/
|
||||
runs/
|
||||
wandb/
|
||||
mlruns/
|
||||
.mlflow/
|
||||
|
||||
# Temporary files
|
||||
temp/
|
||||
tmp/
|
||||
*.tmp
|
||||
test*.py
|
||||
|
||||
# OS generated files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# IDE files
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# Audio processing temporary files
|
||||
*.spec
|
||||
*.mfcc
|
||||
*.mel
|
||||
|
||||
# Frontend build files
|
||||
audio-classification-platform/frontend/dist/
|
||||
audio-classification-platform/frontend/build/
|
||||
audio-classification-platform/frontend/.vite/
|
||||
|
||||
# Uploaded files directory
|
||||
audio-classification-platform/backend/uploads/
|
||||
|
||||
# Local development configuration
|
||||
audio-classification-platform/backend/.env
|
||||
audio-classification-platform/frontend/.env.local
|
||||
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -0,0 +1,39 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# 配置
|
||||
class Config:
|
||||
# 模型配置
|
||||
MODEL_CONFIG_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../configs/cam++.yml'))
|
||||
MODEL_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../models/CAMPPlus_Fbank/best_model/'))
|
||||
LABEL_FILE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../dataset/label_list.txt'))
|
||||
|
||||
# Flask配置
|
||||
SECRET_KEY = 'your-secret-key-here'
|
||||
MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50MB
|
||||
|
||||
# 文件上传配置
|
||||
UPLOAD_FOLDER = 'uploads'
|
||||
ALLOWED_EXTENSIONS = {'wav', 'mp3', 'flac', 'm4a', 'ogg', 'aac'}
|
||||
|
||||
# 音频处理配置
|
||||
TARGET_SAMPLE_RATE = 16000
|
||||
|
||||
# 日志配置
|
||||
LOG_LEVEL = 'INFO'
|
||||
|
||||
# GPU配置
|
||||
USE_GPU = True
|
||||
|
||||
class DevelopmentConfig(Config):
|
||||
DEBUG = True
|
||||
|
||||
class ProductionConfig(Config):
|
||||
DEBUG = False
|
||||
|
||||
# 根据环境变量选择配置
|
||||
config = {
|
||||
'development': DevelopmentConfig,
|
||||
'production': ProductionConfig,
|
||||
'default': DevelopmentConfig
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
Flask==2.3.3
|
||||
Flask-CORS==4.0.0
|
||||
librosa==0.10.1
|
||||
soundfile==0.12.1
|
||||
numpy==1.24.3
|
||||
loguru==0.7.2
|
||||
Werkzeug==2.3.7
|
||||
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>声纹识别系统</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Microsoft YaHei', sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "audio-classification-frontend",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"serve": "vite preview"
|
||||
}, "dependencies": {
|
||||
"vue": "^3.3.4",
|
||||
"vue-router": "^4.2.4",
|
||||
"axios": "^1.5.0",
|
||||
"element-plus": "^2.3.9",
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"echarts": "^5.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.3.4",
|
||||
"vite": "^4.4.9",
|
||||
"unplugin-vue-components": "^0.25.2",
|
||||
"unplugin-auto-import": "^0.16.6"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 主应用组件
|
||||
</script>
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
|
||||
font-family: 'Inter', 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
|
||||
color: #333;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* 全局美化样式 */
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* 自定义滚动条 */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 4px;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
/* 全局动画 */
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideInLeft {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(-30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideInRight {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
#app {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,18 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
// 注册所有图标
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
|
||||
app.use(ElementPlus)
|
||||
app.use(router)
|
||||
|
||||
app.mount('#app')
|
||||
@ -0,0 +1,17 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import HomePage from '../views/HomePage.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: HomePage
|
||||
}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
@ -0,0 +1,33 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
],
|
||||
server: {
|
||||
port: 3000,
|
||||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:5000',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets',
|
||||
chunkSizeWarningLimit: 1000
|
||||
}
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
echo ================================
|
||||
echo 声纹识别系统启动脚本
|
||||
echo ================================
|
||||
echo.
|
||||
|
||||
echo 正在启动后端服务...
|
||||
cd /d "%~dp0backend"
|
||||
start "后端服务" cmd /k "python app.py"
|
||||
|
||||
echo 等待后端服务启动...
|
||||
timeout /t 3 /nobreak >nul
|
||||
|
||||
echo 正在启动前端服务...
|
||||
cd /d "%~dp0frontend"
|
||||
start "前端服务" cmd /k "npm run dev"
|
||||
|
||||
echo.
|
||||
echo 启动完成!
|
||||
echo 后端服务: http://localhost:5000
|
||||
echo 前端服务: http://localhost:3000
|
||||
echo.
|
||||
echo 请等待服务完全启动后访问前端地址
|
||||
pause
|
||||
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "================================"
|
||||
echo " 声纹识别系统启动脚本"
|
||||
echo "================================"
|
||||
echo
|
||||
|
||||
# 获取脚本所在目录
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "正在启动后端服务..."
|
||||
cd "$SCRIPT_DIR/backend"
|
||||
python app.py &
|
||||
BACKEND_PID=$!
|
||||
|
||||
echo "等待后端服务启动..."
|
||||
sleep 3
|
||||
|
||||
echo "正在启动前端服务..."
|
||||
cd "$SCRIPT_DIR/frontend"
|
||||
npm run dev &
|
||||
FRONTEND_PID=$!
|
||||
|
||||
echo
|
||||
echo "启动完成!"
|
||||
echo "后端服务: http://localhost:5000"
|
||||
echo "前端服务: http://localhost:3000"
|
||||
echo
|
||||
echo "后端进程 PID: $BACKEND_PID"
|
||||
echo "前端进程 PID: $FRONTEND_PID"
|
||||
echo
|
||||
echo "按 Ctrl+C 停止所有服务"
|
||||
|
||||
# 等待用户中断
|
||||
trap 'echo "正在停止服务..."; kill $BACKEND_PID $FRONTEND_PID; exit' INT
|
||||
wait
|
||||
@ -0,0 +1,46 @@
|
||||
# 语速增强
|
||||
speed:
|
||||
# 增强概率
|
||||
prob: 1.0
|
||||
|
||||
# 音量增强
|
||||
volume:
|
||||
# 增强概率
|
||||
prob: 0.0
|
||||
# 最小增益
|
||||
min_gain_dBFS: -15
|
||||
# 最大增益
|
||||
max_gain_dBFS: 15
|
||||
|
||||
# 噪声增强
|
||||
noise:
|
||||
# 增强概率
|
||||
prob: 0.5
|
||||
# 噪声增强的噪声文件夹
|
||||
noise_dir: 'dataset/noise'
|
||||
# 针对噪声的最小音量增益
|
||||
min_snr_dB: 10
|
||||
# 针对噪声的最大音量增益
|
||||
max_snr_dB: 50
|
||||
|
||||
# 混响增强
|
||||
reverb:
|
||||
# 增强概率
|
||||
prob: 0.5
|
||||
# 混响增强的混响文件夹
|
||||
reverb_dir: 'dataset/reverb'
|
||||
|
||||
# Spec增强
|
||||
spec_aug:
|
||||
# 增强概率
|
||||
prob: 0.5
|
||||
# 频域掩蔽的比例
|
||||
freq_mask_ratio: 0.1
|
||||
# 频域掩蔽次数
|
||||
n_freq_masks: 1
|
||||
# 频域掩蔽的比例
|
||||
time_mask_ratio: 0.05
|
||||
# 频域掩蔽次数
|
||||
n_time_masks: 1
|
||||
# 最大时间扭曲
|
||||
max_time_warp: 0
|
||||
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 115 KiB |
@ -0,0 +1,19 @@
|
||||
import argparse
|
||||
import functools
|
||||
|
||||
from macls.trainer import MAClsTrainer
|
||||
from macls.utils.utils import add_arguments, print_arguments
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
add_arg = functools.partial(add_arguments, argparser=parser)
|
||||
add_arg('configs', str, 'configs/cam++.yml', '配置文件')
|
||||
add_arg('save_dir', str, 'dataset/features', '保存特征的路径')
|
||||
add_arg('max_duration', int, 100, '提取特征的最大时长,避免过长显存不足,单位秒')
|
||||
args = parser.parse_args()
|
||||
print_arguments(args=args)
|
||||
|
||||
# 获取训练器
|
||||
trainer = MAClsTrainer(configs=args.configs)
|
||||
|
||||
# 提取特征保存文件
|
||||
trainer.extract_features(save_dir=args.save_dir, max_duration=args.max_duration)
|
||||
@ -0,0 +1,23 @@
|
||||
import argparse
|
||||
import functools
|
||||
|
||||
from macls.predict import MAClsPredictor
|
||||
from macls.utils.utils import add_arguments, print_arguments
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
add_arg = functools.partial(add_arguments, argparser=parser)
|
||||
add_arg('configs', str, 'configs/cam++.yml', '配置文件')
|
||||
add_arg('use_gpu', bool, True, '是否使用GPU预测')
|
||||
add_arg('audio_path', str, 'dataset/UrbanSound8K/audio/fold5/156634-5-2-5.wav', '音频路径')
|
||||
add_arg('model_path', str, 'models/CAMPPlus_Fbank/best_model/', '导出的预测模型文件路径')
|
||||
args = parser.parse_args()
|
||||
print_arguments(args=args)
|
||||
|
||||
# 获取识别器
|
||||
predictor = MAClsPredictor(configs=args.configs,
|
||||
model_path=args.model_path,
|
||||
use_gpu=args.use_gpu)
|
||||
|
||||
label, score = predictor.predict(audio_data=args.audio_path)
|
||||
|
||||
print(f'音频:{args.audio_path} 的预测结果标签为:{label},得分:{score}')
|
||||
@ -0,0 +1,58 @@
|
||||
import argparse
|
||||
import functools
|
||||
import threading
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import soundcard as sc
|
||||
|
||||
from macls.predict import MAClsPredictor
|
||||
from macls.utils.utils import add_arguments, print_arguments
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
add_arg = functools.partial(add_arguments, argparser=parser)
|
||||
add_arg('configs', str, 'configs/cam++.yml', '配置文件')
|
||||
add_arg('use_gpu', bool, True, '是否使用GPU预测')
|
||||
add_arg('record_seconds', float, 3, '录音长度')
|
||||
add_arg('model_path', str, 'models/CAMPPlus_Fbank/best_model/', '导出的预测模型文件路径')
|
||||
args = parser.parse_args()
|
||||
print_arguments(args=args)
|
||||
|
||||
# 获取识别器
|
||||
predictor = MAClsPredictor(configs=args.configs,
|
||||
model_path=args.model_path,
|
||||
use_gpu=args.use_gpu)
|
||||
|
||||
all_data = []
|
||||
# 获取默认麦克风
|
||||
default_mic = sc.default_microphone()
|
||||
# 录音采样率
|
||||
samplerate = 16000
|
||||
# 录音块大小
|
||||
numframes = 1024
|
||||
# 模型输入长度
|
||||
infer_len = int(samplerate * args.record_seconds / numframes)
|
||||
|
||||
|
||||
def infer_thread():
|
||||
global all_data
|
||||
s = time.time()
|
||||
while True:
|
||||
if len(all_data) < infer_len: continue
|
||||
# 截取最新的音频数据
|
||||
seg_data = all_data[-infer_len:]
|
||||
d = np.concatenate(seg_data)
|
||||
# 删除旧的音频数据
|
||||
del all_data[:len(all_data) - infer_len]
|
||||
label, score = predictor.predict(audio_data=d, sample_rate=samplerate)
|
||||
print(f'{int(time.time() - s)}s 预测结果标签为:{label},得分:{score}')
|
||||
|
||||
|
||||
thread = threading.Thread(target=infer_thread, args=())
|
||||
thread.start()
|
||||
|
||||
|
||||
with default_mic.recorder(samplerate=samplerate, channels=1) as mic:
|
||||
while True:
|
||||
data = mic.record(numframes=numframes)
|
||||
all_data.append(data)
|
||||
@ -0,0 +1 @@
|
||||
__version__ = "1.0.6"
|
||||
@ -0,0 +1,132 @@
|
||||
import numpy as np
|
||||
import torch
|
||||
import torchaudio.compliance.kaldi as Kaldi
|
||||
from torch import nn
|
||||
from torchaudio.transforms import MelSpectrogram, Spectrogram, MFCC
|
||||
from loguru import logger
|
||||
|
||||
|
||||
class AudioFeaturizer(nn.Module):
|
||||
"""音频特征器
|
||||
|
||||
:param feature_method: 所使用的预处理方法
|
||||
:type feature_method: str
|
||||
:param use_hf_model: 是否使用HF上的Wav2Vec2类似模型提取音频特征
|
||||
:type use_hf_model: bool
|
||||
:param method_args: 预处理方法的参数
|
||||
:type method_args: dict
|
||||
"""
|
||||
|
||||
def __init__(self, feature_method='MelSpectrogram', use_hf_model=False, method_args={}):
|
||||
super().__init__()
|
||||
self._method_args = method_args
|
||||
self._feature_method = feature_method
|
||||
self.use_hf_model = use_hf_model
|
||||
if self.use_hf_model:
|
||||
from transformers import AutoModel, AutoFeatureExtractor
|
||||
# 判断是否使用GPU提取特征
|
||||
use_gpu = torch.cuda.is_available() and method_args.get('use_gpu', True)
|
||||
self.device = torch.device("cuda") if use_gpu else torch.device("cpu")
|
||||
# 加载Wav2Vec2类似模型
|
||||
self.processor = AutoFeatureExtractor.from_pretrained(feature_method)
|
||||
self.feature_model = AutoModel.from_pretrained(feature_method).to(self.device)
|
||||
logger.info(f'使用模型【{feature_method}】提取特征,使用【{self.device}】设备提取')
|
||||
# 获取模型的输出通道数
|
||||
inputs = self.processor(np.ones(16000 * 1, dtype=np.float32), sampling_rate=16000,
|
||||
return_tensors="pt").to(self.device)
|
||||
with torch.no_grad():
|
||||
outputs = self.feature_model(**inputs)
|
||||
self.output_channels = outputs.extract_features.shape[2]
|
||||
else:
|
||||
if feature_method == 'MelSpectrogram':
|
||||
self.feat_fun = MelSpectrogram(**method_args)
|
||||
elif feature_method == 'Spectrogram':
|
||||
self.feat_fun = Spectrogram(**method_args)
|
||||
elif feature_method == 'MFCC':
|
||||
self.feat_fun = MFCC(**method_args)
|
||||
elif feature_method == 'Fbank':
|
||||
self.feat_fun = KaldiFbank(**method_args)
|
||||
else:
|
||||
raise Exception(f'预处理方法 {self._feature_method} 不存在!')
|
||||
logger.info(f'使用【{feature_method}】提取特征')
|
||||
|
||||
def forward(self, waveforms, input_lens_ratio=None):
|
||||
"""从AudioSegment中提取音频特征
|
||||
|
||||
:param waveforms: Audio segment to extract features from.
|
||||
:type waveforms: AudioSegment
|
||||
:param input_lens_ratio: input length ratio
|
||||
:type input_lens_ratio: tensor
|
||||
:return: Spectrogram audio feature in 2darray.
|
||||
:rtype: ndarray
|
||||
"""
|
||||
if len(waveforms.shape) == 1:
|
||||
waveforms = waveforms.unsqueeze(0)
|
||||
if self.use_hf_model:
|
||||
# 使用HF上的Wav2Vec2类似模型提取音频特征
|
||||
if isinstance(waveforms, torch.Tensor):
|
||||
waveforms = waveforms.numpy()
|
||||
inputs = self.processor(waveforms, sampling_rate=16000,
|
||||
return_tensors="pt").to(self.device)
|
||||
with torch.no_grad():
|
||||
outputs = self.feature_model(**inputs)
|
||||
feature = outputs.extract_features.cpu().detach()
|
||||
else:
|
||||
# 使用普通方法提取音频特征
|
||||
feature = self.feat_fun(waveforms)
|
||||
feature = feature.transpose(2, 1)
|
||||
# 归一化
|
||||
feature = feature - feature.mean(1, keepdim=True)
|
||||
if input_lens_ratio is not None:
|
||||
# 对掩码比例进行扩展
|
||||
input_lens = (input_lens_ratio * feature.shape[1])
|
||||
mask_lens = torch.round(input_lens).long()
|
||||
mask_lens = mask_lens.unsqueeze(1)
|
||||
# 生成掩码张量
|
||||
idxs = torch.arange(feature.shape[1], device=feature.device).repeat(feature.shape[0], 1)
|
||||
mask = idxs < mask_lens
|
||||
mask = mask.unsqueeze(-1)
|
||||
# 对特征进行掩码操作
|
||||
feature = torch.where(mask, feature, torch.zeros_like(feature))
|
||||
return feature
|
||||
|
||||
@property
|
||||
def feature_dim(self):
|
||||
"""返回特征大小
|
||||
|
||||
:return: 特征大小
|
||||
:rtype: int
|
||||
"""
|
||||
if self.use_hf_model:
|
||||
return self.output_channels
|
||||
if self._feature_method == 'MelSpectrogram':
|
||||
return self._method_args.get('n_mels', 128)
|
||||
elif self._feature_method == 'Spectrogram':
|
||||
return self._method_args.get('n_fft', 400) // 2 + 1
|
||||
elif self._feature_method == 'MFCC':
|
||||
return self._method_args.get('n_mfcc', 40)
|
||||
elif self._feature_method == 'Fbank':
|
||||
return self._method_args.get('num_mel_bins', 23)
|
||||
else:
|
||||
raise Exception('没有{}预处理方法'.format(self._feature_method))
|
||||
|
||||
|
||||
class KaldiFbank(nn.Module):
|
||||
def __init__(self, **kwargs):
|
||||
super(KaldiFbank, self).__init__()
|
||||
self.kwargs = kwargs
|
||||
|
||||
def forward(self, waveforms):
|
||||
"""
|
||||
:param waveforms: [Batch, Length]
|
||||
:return: [Batch, Feature, Length]
|
||||
"""
|
||||
log_fbanks = []
|
||||
for waveform in waveforms:
|
||||
if len(waveform.shape) == 1:
|
||||
waveform = waveform.unsqueeze(0)
|
||||
log_fbank = Kaldi.fbank(waveform, **self.kwargs)
|
||||
log_fbank = log_fbank.transpose(0, 1)
|
||||
log_fbanks.append(log_fbank)
|
||||
log_fbank = torch.stack(log_fbanks)
|
||||
return log_fbank
|
||||
@ -0,0 +1,12 @@
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
|
||||
# 计算准确率
|
||||
def accuracy(output, label):
|
||||
output = torch.nn.functional.softmax(output, dim=-1)
|
||||
output = output.data.cpu().numpy()
|
||||
output = np.argmax(output, axis=1)
|
||||
label = label.data.cpu().numpy()
|
||||
acc = np.mean((output == label).astype(int))
|
||||
return acc
|
||||
@ -0,0 +1,32 @@
|
||||
import importlib
|
||||
|
||||
from loguru import logger
|
||||
from torch.optim import *
|
||||
from .scheduler import WarmupCosineSchedulerLR
|
||||
from torch.optim.lr_scheduler import *
|
||||
|
||||
__all__ = ['build_optimizer', 'build_lr_scheduler']
|
||||
|
||||
|
||||
def build_optimizer(params, configs):
|
||||
use_optimizer = configs.optimizer_conf.get('optimizer', 'Adam')
|
||||
optimizer_args = configs.optimizer_conf.get('optimizer_args', {})
|
||||
optim = importlib.import_module(__name__)
|
||||
optimizer = getattr(optim, use_optimizer)(params=params, **optimizer_args)
|
||||
logger.info(f'成功创建优化方法:{use_optimizer},参数为:{optimizer_args}')
|
||||
return optimizer
|
||||
|
||||
|
||||
def build_lr_scheduler(optimizer, step_per_epoch, configs):
|
||||
use_scheduler = configs.optimizer_conf.get('scheduler', 'WarmupCosineSchedulerLR')
|
||||
scheduler_args = configs.optimizer_conf.get('scheduler_args', {})
|
||||
if configs.optimizer_conf.scheduler == 'CosineAnnealingLR' and 'T_max' not in scheduler_args:
|
||||
scheduler_args.T_max = int(configs.train_conf.max_epoch * 1.2) * step_per_epoch
|
||||
if configs.optimizer_conf.scheduler == 'WarmupCosineSchedulerLR' and 'fix_epoch' not in scheduler_args:
|
||||
scheduler_args.fix_epoch = configs.train_conf.max_epoch
|
||||
if configs.optimizer_conf.scheduler == 'WarmupCosineSchedulerLR' and 'step_per_epoch' not in scheduler_args:
|
||||
scheduler_args.step_per_epoch = step_per_epoch
|
||||
optim = importlib.import_module(__name__)
|
||||
scheduler = getattr(optim, use_scheduler)(optimizer=optimizer, **scheduler_args)
|
||||
logger.info(f'成功创建学习率衰减:{use_scheduler},参数为:{scheduler_args}')
|
||||
return scheduler
|
||||
@ -0,0 +1,48 @@
|
||||
import math
|
||||
from typing import List
|
||||
|
||||
|
||||
class WarmupCosineSchedulerLR:
|
||||
def __init__(
|
||||
self,
|
||||
optimizer,
|
||||
min_lr,
|
||||
max_lr,
|
||||
warmup_epoch,
|
||||
fix_epoch,
|
||||
step_per_epoch
|
||||
):
|
||||
self.optimizer = optimizer
|
||||
assert min_lr <= max_lr
|
||||
self.min_lr = min_lr
|
||||
self.max_lr = max_lr
|
||||
self.warmup_step = warmup_epoch * step_per_epoch
|
||||
self.fix_step = fix_epoch * step_per_epoch
|
||||
self.current_step = 0.0
|
||||
|
||||
def set_lr(self, ):
|
||||
new_lr = self.clr(self.current_step)
|
||||
for param_group in self.optimizer.param_groups:
|
||||
param_group['lr'] = new_lr
|
||||
return new_lr
|
||||
|
||||
def step(self, step=None):
|
||||
if step is not None:
|
||||
self.current_step = step
|
||||
new_lr = self.set_lr()
|
||||
self.current_step += 1
|
||||
return new_lr
|
||||
|
||||
def clr(self, step):
|
||||
if step < self.warmup_step:
|
||||
return self.min_lr + (self.max_lr - self.min_lr) * \
|
||||
(step / self.warmup_step)
|
||||
elif self.warmup_step <= step < self.fix_step:
|
||||
return self.min_lr + 0.5 * (self.max_lr - self.min_lr) * \
|
||||
(1 + math.cos(math.pi * (step - self.warmup_step) /
|
||||
(self.fix_step - self.warmup_step)))
|
||||
else:
|
||||
return self.min_lr
|
||||
|
||||
def get_last_lr(self) -> List[float]:
|
||||
return [self.clr(self.current_step)]
|
||||
@ -0,0 +1,162 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import torch
|
||||
from loguru import logger
|
||||
from macls import __version__
|
||||
|
||||
|
||||
def load_pretrained(model, pretrained_model, use_gpu=True):
|
||||
"""加载预训练模型
|
||||
|
||||
:param model: 使用的模型
|
||||
:param pretrained_model: 预训练模型路径
|
||||
:param use_gpu: 模型是否使用GPU
|
||||
:return: 加载的模型
|
||||
"""
|
||||
# 加载预训练模型
|
||||
if pretrained_model is None: return model
|
||||
if os.path.isdir(pretrained_model):
|
||||
pretrained_model = os.path.join(pretrained_model, 'model.pth')
|
||||
assert os.path.exists(pretrained_model), f"{pretrained_model} 模型不存在!"
|
||||
if isinstance(model, torch.nn.parallel.DistributedDataParallel):
|
||||
model_dict = model.module.state_dict()
|
||||
else:
|
||||
model_dict = model.state_dict()
|
||||
if torch.cuda.is_available() and use_gpu:
|
||||
model_state_dict = torch.load(pretrained_model, weights_only=False)
|
||||
else:
|
||||
model_state_dict = torch.load(pretrained_model, weights_only=False, map_location='cpu')
|
||||
# 过滤不存在的参数
|
||||
for name, weight in model_dict.items():
|
||||
if name in model_state_dict.keys():
|
||||
if list(weight.shape) != list(model_state_dict[name].shape):
|
||||
logger.warning(f'{name} not used, shape {list(model_state_dict[name].shape)} '
|
||||
f'unmatched with {list(weight.shape)} in model.')
|
||||
model_state_dict.pop(name, None)
|
||||
# 加载权重
|
||||
if isinstance(model, torch.nn.parallel.DistributedDataParallel):
|
||||
missing_keys, unexpected_keys = model.module.load_state_dict(model_state_dict, strict=False)
|
||||
else:
|
||||
missing_keys, unexpected_keys = model.load_state_dict(model_state_dict, strict=False)
|
||||
if len(unexpected_keys) > 0:
|
||||
logger.warning('Unexpected key(s) in state_dict: {}. '
|
||||
.format(', '.join('"{}"'.format(k) for k in unexpected_keys)))
|
||||
if len(missing_keys) > 0:
|
||||
logger.warning('Missing key(s) in state_dict: {}. '
|
||||
.format(', '.join('"{}"'.format(k) for k in missing_keys)))
|
||||
logger.info('成功加载预训练模型:{}'.format(pretrained_model))
|
||||
return model
|
||||
|
||||
|
||||
def load_checkpoint(configs, model, optimizer, amp_scaler, scheduler,
|
||||
step_epoch, save_model_path, resume_model):
|
||||
"""加载模型
|
||||
|
||||
:param configs: 配置信息
|
||||
:param model: 使用的模型
|
||||
:param optimizer: 使用的优化方法
|
||||
:param amp_scaler: 使用的自动混合精度
|
||||
:param scheduler: 使用的学习率调整策略
|
||||
:param step_epoch: 每个epoch的step数量
|
||||
:param save_model_path: 模型保存路径
|
||||
:param resume_model: 恢复训练的模型路径
|
||||
"""
|
||||
last_epoch1 = 0
|
||||
accuracy1 = 0.
|
||||
|
||||
def load_model(model_path):
|
||||
assert os.path.exists(os.path.join(model_path, 'model.pth')), "模型参数文件不存在!"
|
||||
assert os.path.exists(os.path.join(model_path, 'optimizer.pth')), "优化方法参数文件不存在!"
|
||||
state_dict = torch.load(os.path.join(model_path, 'model.pth'), weights_only=False)
|
||||
if isinstance(model, torch.nn.parallel.DistributedDataParallel):
|
||||
model.module.load_state_dict(state_dict)
|
||||
else:
|
||||
model.load_state_dict(state_dict)
|
||||
optimizer.load_state_dict(torch.load(os.path.join(model_path, 'optimizer.pth'), weights_only=False))
|
||||
# 自动混合精度参数
|
||||
if amp_scaler is not None and os.path.exists(os.path.join(model_path, 'scaler.pth')):
|
||||
amp_scaler.load_state_dict(torch.load(os.path.join(model_path, 'scaler.pth')), weights_only=False)
|
||||
with open(os.path.join(model_path, 'model.state'), 'r', encoding='utf-8') as f:
|
||||
json_data = json.load(f)
|
||||
last_epoch = json_data['last_epoch']
|
||||
accuracy = json_data['accuracy']
|
||||
logger.info('成功恢复模型参数和优化方法参数:{}'.format(model_path))
|
||||
optimizer.step()
|
||||
[scheduler.step() for _ in range(last_epoch * step_epoch)]
|
||||
return last_epoch, accuracy
|
||||
|
||||
# 获取最后一个保存的模型
|
||||
save_feature_method = configs.preprocess_conf.feature_method
|
||||
if configs.preprocess_conf.get('use_hf_model', False):
|
||||
save_feature_method = save_feature_method[:-1] if save_feature_method[-1] == '/' else save_feature_method
|
||||
save_feature_method = os.path.basename(save_feature_method)
|
||||
last_model_dir = os.path.join(save_model_path,
|
||||
f'{configs.model_conf.model}_{save_feature_method}',
|
||||
'last_model')
|
||||
if resume_model is not None or (os.path.exists(os.path.join(last_model_dir, 'model.pth'))
|
||||
and os.path.exists(os.path.join(last_model_dir, 'optimizer.pth'))):
|
||||
if resume_model is not None:
|
||||
last_epoch1, accuracy1 = load_model(resume_model)
|
||||
else:
|
||||
try:
|
||||
# 自动获取最新保存的模型
|
||||
last_epoch1, accuracy1 = load_model(last_model_dir)
|
||||
except Exception as e:
|
||||
logger.warning(f'尝试自动恢复最新模型失败,错误信息:{e}')
|
||||
return model, optimizer, amp_scaler, scheduler, last_epoch1, accuracy1
|
||||
|
||||
|
||||
# 保存模型
|
||||
def save_checkpoint(configs, model, optimizer, amp_scaler, save_model_path, epoch_id,
|
||||
accuracy=0., best_model=False):
|
||||
"""保存模型
|
||||
|
||||
:param configs: 配置信息
|
||||
:param model: 使用的模型
|
||||
:param optimizer: 使用的优化方法
|
||||
:param amp_scaler: 使用的自动混合精度
|
||||
:param save_model_path: 模型保存路径
|
||||
:param epoch_id: 当前epoch
|
||||
:param accuracy: 当前准确率
|
||||
:param best_model: 是否为最佳模型
|
||||
"""
|
||||
if isinstance(model, torch.nn.parallel.DistributedDataParallel):
|
||||
state_dict = model.module.state_dict()
|
||||
else:
|
||||
state_dict = model.state_dict()
|
||||
# 保存模型的路径
|
||||
save_feature_method = configs.preprocess_conf.feature_method
|
||||
if configs.preprocess_conf.get('use_hf_model', False):
|
||||
save_feature_method = save_feature_method[:-1] if save_feature_method[-1] == '/' else save_feature_method
|
||||
save_feature_method = os.path.basename(save_feature_method)
|
||||
if best_model:
|
||||
model_path = os.path.join(save_model_path,
|
||||
f'{configs.model_conf.model}_{save_feature_method}', 'best_model')
|
||||
else:
|
||||
model_path = os.path.join(save_model_path,
|
||||
f'{configs.model_conf.model}_{save_feature_method}', 'epoch_{}'.format(epoch_id))
|
||||
os.makedirs(model_path, exist_ok=True)
|
||||
# 保存模型参数
|
||||
torch.save(optimizer.state_dict(), os.path.join(model_path, 'optimizer.pth'))
|
||||
torch.save(state_dict, os.path.join(model_path, 'model.pth'))
|
||||
# 自动混合精度参数
|
||||
if amp_scaler is not None:
|
||||
torch.save(amp_scaler.state_dict(), os.path.join(model_path, 'scaler.pth'))
|
||||
with open(os.path.join(model_path, 'model.state'), 'w', encoding='utf-8') as f:
|
||||
data = {"last_epoch": epoch_id, "accuracy": accuracy, "version": __version__,
|
||||
"model": configs.model_conf.model, "feature_method": save_feature_method}
|
||||
f.write(json.dumps(data, indent=4, ensure_ascii=False))
|
||||
if not best_model:
|
||||
last_model_path = os.path.join(save_model_path,
|
||||
f'{configs.model_conf.model}_{save_feature_method}', 'last_model')
|
||||
shutil.rmtree(last_model_path, ignore_errors=True)
|
||||
shutil.copytree(model_path, last_model_path)
|
||||
# 删除旧的模型
|
||||
old_model_path = os.path.join(save_model_path,
|
||||
f'{configs.model_conf.model}_{save_feature_method}',
|
||||
'epoch_{}'.format(epoch_id - 3))
|
||||
if os.path.exists(old_model_path):
|
||||
shutil.rmtree(old_model_path)
|
||||
logger.info('已保存模型:{}'.format(model_path))
|
||||
@ -0,0 +1,14 @@
|
||||
import time
|
||||
|
||||
from macls.utils.record import RecordAudio
|
||||
|
||||
s = input('请输入你计划录音多少秒:')
|
||||
record_seconds = int(s)
|
||||
save_path = "dataset/save_audio/%s.wav" % str(int(time.time()*1000))
|
||||
|
||||
record_audio = RecordAudio()
|
||||
input(f"按下回车键开机录音,录音{record_seconds}秒中:")
|
||||
record_audio.record(record_seconds=record_seconds,
|
||||
save_path=save_path)
|
||||
|
||||
print('文件保存在:%s' % save_path)
|
||||
@ -0,0 +1,17 @@
|
||||
numpy>=1.19.2
|
||||
scipy>=1.6.3
|
||||
librosa>=0.9.1
|
||||
soundfile>=0.12.1
|
||||
soundcard>=0.4.2
|
||||
resampy>=0.2.2
|
||||
numba>=0.53.0
|
||||
pydub~=0.25.1
|
||||
matplotlib>=3.5.2
|
||||
pillow>=10.3.0
|
||||
tqdm>=4.66.3
|
||||
visualdl==2.5.3
|
||||
pyyaml>=5.4.1
|
||||
scikit-learn>=1.0.2
|
||||
torchinfo>=1.7.2
|
||||
loguru>=0.7.2
|
||||
yeaudio>=0.0.7
|
||||
@ -0,0 +1,54 @@
|
||||
import shutil
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
import macls
|
||||
|
||||
VERSION = macls.__version__
|
||||
|
||||
# 复制配置文件到项目目录下
|
||||
shutil.rmtree('./macls/configs/', ignore_errors=True)
|
||||
shutil.copytree('./configs/', './macls/configs/')
|
||||
|
||||
|
||||
def readme():
|
||||
with open('README.md', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
return content
|
||||
|
||||
|
||||
def parse_requirements():
|
||||
with open('./requirements.txt', encoding="utf-8") as f:
|
||||
requirements = f.readlines()
|
||||
return requirements
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup(
|
||||
name='macls',
|
||||
packages=find_packages(),
|
||||
package_data={'': ['configs/*']},
|
||||
author='yeyupiaoling',
|
||||
version=VERSION,
|
||||
install_requires=parse_requirements(),
|
||||
description='Audio Classification toolkit on Pytorch',
|
||||
long_description=readme(),
|
||||
long_description_content_type='text/markdown',
|
||||
url='https://github.com/yeyupiaoling/AudioClassification-Pytorch',
|
||||
download_url='https://github.com/yeyupiaoling/AudioClassification-Pytorch.git',
|
||||
keywords=['audio', 'pytorch'],
|
||||
classifiers=[
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Operating System :: OS Independent',
|
||||
'Natural Language :: Chinese (Simplified)',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9', 'Topic :: Utilities'
|
||||
],
|
||||
license='Apache License 2.0',
|
||||
ext_modules=[])
|
||||
shutil.rmtree('./macls/configs/', ignore_errors=True)
|
||||
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
download_dir=dataset/language
|
||||
|
||||
|
||||
[ ! -d ${download_dir} ] && mkdir -p ${download_dir}
|
||||
|
||||
if [ ! -f ${download_dir}/test.tar.gz ]; then
|
||||
echo "准备下载测试集"
|
||||
wget --no-check-certificate https://speech-lab-share-data.oss-cn-shanghai.aliyuncs.com/3D-Speaker/test.tar.gz -P ${download_dir}
|
||||
md5=$(md5sum ${download_dir}/test.tar.gz | awk '{print $1}')
|
||||
[ $md5 != "45972606dd10d3f7c1c31f27acdfbed7" ] && echo "Wrong md5sum of 3dspeaker test.tar.gz" && exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f ${download_dir}/train.tar.gz ]; then
|
||||
echo "准备下载训练集"
|
||||
wget --no-check-certificate https://speech-lab-share-data.oss-cn-shanghai.aliyuncs.com/3D-Speaker/train.tar.gz -P ${download_dir}
|
||||
md5=$(md5sum ${download_dir}/train.tar.gz | awk '{print $1}')
|
||||
[ $md5 != "c2cea55fd22a2b867d295fb35a2d3340" ] && echo "Wrong md5sum of 3dspeaker train.tar.gz" && exit 1
|
||||
fi
|
||||
|
||||
echo "下载完成!"
|
||||
|
||||
echo "准备解压"
|
||||
|
||||
tar -zxvf ${download_dir}/train.tar.gz -C ${rawdata_dir}/
|
||||
tar -xzvf ${download_dir}/test.tar.gz -C ${rawdata_dir}/
|
||||
|
||||
echo "解压完成!"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue