helvekami commited on
Commit
406d6a6
1 Parent(s): 483dfd2

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.ipynb +44 -66
  2. app.py +0 -1
  3. requirements.txt +9 -1
app.ipynb CHANGED
@@ -6,25 +6,29 @@
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
- "#|default_exp app\n",
10
- "import fastbook\n",
11
- "fastbook.setup_book()\n",
12
- "from fastbook import *\n",
13
- "from fastai.vision.widgets import *\n",
 
 
 
 
 
 
14
  "import librosa.display\n",
15
  "import matplotlib.pyplot as plt\n",
16
  "import numpy as np\n",
17
- "from functools import partial\n",
18
- "from pathlib import Path\n",
19
  "import pandas as pd\n",
20
  "import librosa\n",
21
  "from scipy.io import wavfile\n",
22
- "import gradio as gr \n"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
- "execution_count": 2,
28
  "metadata": {},
29
  "outputs": [],
30
  "source": [
@@ -41,16 +45,16 @@
41
  },
42
  {
43
  "cell_type": "code",
44
- "execution_count": 6,
45
  "metadata": {},
46
  "outputs": [
47
  {
48
  "data": {
49
  "text/plain": [
50
- "<fastai.learner.Learner at 0x7fae08e54250>"
51
  ]
52
  },
53
- "execution_count": 6,
54
  "metadata": {},
55
  "output_type": "execute_result"
56
  }
@@ -63,7 +67,7 @@
63
  },
64
  {
65
  "cell_type": "code",
66
- "execution_count": 7,
67
  "metadata": {},
68
  "outputs": [
69
  {
@@ -73,7 +77,7 @@
73
  "PILImage mode=RGB size=1200x800"
74
  ]
75
  },
76
- "execution_count": 7,
77
  "metadata": {},
78
  "output_type": "execute_result"
79
  }
@@ -86,16 +90,25 @@
86
  },
87
  {
88
  "cell_type": "code",
89
- "execution_count": 8,
90
  "metadata": {},
91
- "outputs": [],
 
 
 
 
 
 
 
 
92
  "source": [
 
93
  "pred,pred_idx,probs = learn.predict('brass_acoustic_006-065-127.png')"
94
  ]
95
  },
96
  {
97
  "cell_type": "code",
98
- "execution_count": 9,
99
  "metadata": {},
100
  "outputs": [],
101
  "source": [
@@ -111,7 +124,7 @@
111
  },
112
  {
113
  "cell_type": "code",
114
- "execution_count": 10,
115
  "metadata": {},
116
  "outputs": [
117
  {
@@ -127,7 +140,7 @@
127
  "data": {
128
  "text/plain": []
129
  },
130
- "execution_count": 10,
131
  "metadata": {},
132
  "output_type": "execute_result"
133
  }
@@ -143,23 +156,23 @@
143
  },
144
  {
145
  "cell_type": "code",
146
- "execution_count": 11,
147
  "metadata": {},
148
  "outputs": [
149
  {
150
  "data": {
151
  "text/plain": [
152
- "{'Brass': 0.006057440303266048,\n",
153
- " 'Flute': 0.9939332604408264,\n",
154
- " 'Guitar': 1.130039848362685e-07,\n",
155
- " 'Keyboard': 2.9415216431516455e-06,\n",
156
- " 'Mallet': 9.832748446569894e-07,\n",
157
- " 'Reed': 8.071441470747232e-08,\n",
158
- " 'String': 1.5890701661191997e-06,\n",
159
- " 'Vocal': 3.567040039342828e-06}"
160
  ]
161
  },
162
- "execution_count": 11,
163
  "metadata": {},
164
  "output_type": "execute_result"
165
  }
@@ -170,44 +183,9 @@
170
  },
171
  {
172
  "cell_type": "code",
173
- "execution_count": 12,
174
  "metadata": {},
175
- "outputs": [
176
- {
177
- "name": "stderr",
178
- "output_type": "stream",
179
- "text": [
180
- "Traceback (most recent call last):\n",
181
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/gradio/routes.py\", line 394, in run_predict\n",
182
- " output = await app.get_blocks().process_api(\n",
183
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/gradio/blocks.py\", line 1075, in process_api\n",
184
- " result = await self.call_function(\n",
185
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/gradio/blocks.py\", line 884, in call_function\n",
186
- " prediction = await anyio.to_thread.run_sync(\n",
187
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/anyio/to_thread.py\", line 31, in run_sync\n",
188
- " return await get_asynclib().run_sync_in_worker_thread(\n",
189
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/anyio/_backends/_asyncio.py\", line 937, in run_sync_in_worker_thread\n",
190
- " return await future\n",
191
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/anyio/_backends/_asyncio.py\", line 867, in run\n",
192
- " result = context.run(func, *args)\n",
193
- " File \"/var/folders/tt/mvwksx9j26jc7y2pzqs4hc5w0000gn/T/ipykernel_80180/1944337707.py\", line 5, in classify_aud\n",
194
- " log_mel_spec_tfm(aud)\n",
195
- " File \"/var/folders/tt/mvwksx9j26jc7y2pzqs4hc5w0000gn/T/ipykernel_80180/1469699344.py\", line 3, in log_mel_spec_tfm\n",
196
- " y, sr = librosa.load(fname, mono=True)\n",
197
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/librosa/util/decorators.py\", line 88, in inner_f\n",
198
- " return f(*args, **kwargs)\n",
199
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/librosa/core/audio.py\", line 164, in load\n",
200
- " y, sr_native = __soundfile_load(path, offset, duration, dtype)\n",
201
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/librosa/core/audio.py\", line 195, in __soundfile_load\n",
202
- " context = sf.SoundFile(path)\n",
203
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/soundfile.py\", line 658, in __init__\n",
204
- " self._file = self._open(file, mode_int, closefd)\n",
205
- " File \"/Users/unnikrishnannambiar/anaconda3/lib/python3.9/site-packages/soundfile.py\", line 1212, in _open\n",
206
- " raise TypeError(\"Invalid file: {0!r}\".format(self.name))\n",
207
- "TypeError: Invalid file: (16000, array([28, 40, 27, ..., 0, 0, 0], dtype=int16))\n"
208
- ]
209
- }
210
- ],
211
  "source": [
212
  "from nbdev.export import nb_export\n",
213
  "from nbdev.release import write_requirements\n",
 
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
+ "#|default_exp app"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 2,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "#|export\n",
19
+ "from fastai.vision.all import *\n",
20
  "import librosa.display\n",
21
  "import matplotlib.pyplot as plt\n",
22
  "import numpy as np\n",
 
 
23
  "import pandas as pd\n",
24
  "import librosa\n",
25
  "from scipy.io import wavfile\n",
26
+ "import gradio as gr "
27
  ]
28
  },
29
  {
30
  "cell_type": "code",
31
+ "execution_count": 3,
32
  "metadata": {},
33
  "outputs": [],
34
  "source": [
 
45
  },
46
  {
47
  "cell_type": "code",
48
+ "execution_count": 4,
49
  "metadata": {},
50
  "outputs": [
51
  {
52
  "data": {
53
  "text/plain": [
54
+ "<fastai.learner.Learner at 0x7f84b9711220>"
55
  ]
56
  },
57
+ "execution_count": 4,
58
  "metadata": {},
59
  "output_type": "execute_result"
60
  }
 
67
  },
68
  {
69
  "cell_type": "code",
70
+ "execution_count": 5,
71
  "metadata": {},
72
  "outputs": [
73
  {
 
77
  "PILImage mode=RGB size=1200x800"
78
  ]
79
  },
80
+ "execution_count": 5,
81
  "metadata": {},
82
  "output_type": "execute_result"
83
  }
 
90
  },
91
  {
92
  "cell_type": "code",
93
+ "execution_count": 6,
94
  "metadata": {},
95
+ "outputs": [
96
+ {
97
+ "name": "stderr",
98
+ "output_type": "stream",
99
+ "text": [
100
+ "[W NNPACK.cpp:53] Could not initialize NNPACK! Reason: Unsupported hardware.\n"
101
+ ]
102
+ }
103
+ ],
104
  "source": [
105
+ "learn.remove_cb(ProgressCallback)\n",
106
  "pred,pred_idx,probs = learn.predict('brass_acoustic_006-065-127.png')"
107
  ]
108
  },
109
  {
110
  "cell_type": "code",
111
+ "execution_count": 7,
112
  "metadata": {},
113
  "outputs": [],
114
  "source": [
 
124
  },
125
  {
126
  "cell_type": "code",
127
+ "execution_count": 8,
128
  "metadata": {},
129
  "outputs": [
130
  {
 
140
  "data": {
141
  "text/plain": []
142
  },
143
+ "execution_count": 8,
144
  "metadata": {},
145
  "output_type": "execute_result"
146
  }
 
156
  },
157
  {
158
  "cell_type": "code",
159
+ "execution_count": 10,
160
  "metadata": {},
161
  "outputs": [
162
  {
163
  "data": {
164
  "text/plain": [
165
+ "{'Brass': 1.0856560038519092e-05,\n",
166
+ " 'Flute': 0.9999878406524658,\n",
167
+ " 'Guitar': 5.949047504616445e-11,\n",
168
+ " 'Keyboard': 1.094620643016242e-07,\n",
169
+ " 'Mallet': 1.3334407356069278e-08,\n",
170
+ " 'Reed': 2.7653837553209826e-10,\n",
171
+ " 'String': 1.1356026163866773e-07,\n",
172
+ " 'Vocal': 1.0655742244125577e-06}"
173
  ]
174
  },
175
+ "execution_count": 10,
176
  "metadata": {},
177
  "output_type": "execute_result"
178
  }
 
183
  },
184
  {
185
  "cell_type": "code",
186
+ "execution_count": 11,
187
  "metadata": {},
188
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  "source": [
190
  "from nbdev.export import nb_export\n",
191
  "from nbdev.release import write_requirements\n",
app.py CHANGED
@@ -7,7 +7,6 @@ from fastai.vision.all import *
7
  import librosa.display
8
  import matplotlib.pyplot as plt
9
  import numpy as np
10
- from functools import partial
11
  import pandas as pd
12
  import librosa
13
  from scipy.io import wavfile
 
7
  import librosa.display
8
  import matplotlib.pyplot as plt
9
  import numpy as np
 
10
  import pandas as pd
11
  import librosa
12
  from scipy.io import wavfile
requirements.txt CHANGED
@@ -1 +1,9 @@
1
-
 
 
 
 
 
 
 
 
 
1
+ fastai
2
+ librosa
3
+ matplotlib
4
+ numpy
5
+ functools
6
+ pandas
7
+ librosa
8
+ scipy
9
+ gradio