KingLLM commited on
Commit
e4e05d9
1 Parent(s): 28847c0

Upload SpeechImageAI (1).ipynb

Browse files
Files changed (1) hide show
  1. SpeechImageAI (1).ipynb +1229 -0
SpeechImageAI (1).ipynb ADDED
@@ -0,0 +1,1229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "language_info": {
14
+ "name": "python"
15
+ },
16
+ "accelerator": "GPU",
17
+ "widgets": {
18
+ "application/vnd.jupyter.widget-state+json": {
19
+ "2f36b8ed6b5f47c9beffb251660ab817": {
20
+ "model_module": "@jupyter-widgets/controls",
21
+ "model_name": "HBoxModel",
22
+ "model_module_version": "1.5.0",
23
+ "state": {
24
+ "_dom_classes": [],
25
+ "_model_module": "@jupyter-widgets/controls",
26
+ "_model_module_version": "1.5.0",
27
+ "_model_name": "HBoxModel",
28
+ "_view_count": null,
29
+ "_view_module": "@jupyter-widgets/controls",
30
+ "_view_module_version": "1.5.0",
31
+ "_view_name": "HBoxView",
32
+ "box_style": "",
33
+ "children": [
34
+ "IPY_MODEL_dd79591e26d54d749f84339205484e50",
35
+ "IPY_MODEL_6b4a398fb55d4b509188d16cd66615ed",
36
+ "IPY_MODEL_419f9b313a5e4fb5b5a5b1c8db30cd27"
37
+ ],
38
+ "layout": "IPY_MODEL_39f7db24cde842828d2b2f10b947c9b3"
39
+ }
40
+ },
41
+ "dd79591e26d54d749f84339205484e50": {
42
+ "model_module": "@jupyter-widgets/controls",
43
+ "model_name": "HTMLModel",
44
+ "model_module_version": "1.5.0",
45
+ "state": {
46
+ "_dom_classes": [],
47
+ "_model_module": "@jupyter-widgets/controls",
48
+ "_model_module_version": "1.5.0",
49
+ "_model_name": "HTMLModel",
50
+ "_view_count": null,
51
+ "_view_module": "@jupyter-widgets/controls",
52
+ "_view_module_version": "1.5.0",
53
+ "_view_name": "HTMLView",
54
+ "description": "",
55
+ "description_tooltip": null,
56
+ "layout": "IPY_MODEL_2d0f034676124ae68c8304249b50105a",
57
+ "placeholder": "​",
58
+ "style": "IPY_MODEL_5e30295db2ed4bd1803070be6e39020a",
59
+ "value": "Loading checkpoint shards: 100%"
60
+ }
61
+ },
62
+ "6b4a398fb55d4b509188d16cd66615ed": {
63
+ "model_module": "@jupyter-widgets/controls",
64
+ "model_name": "FloatProgressModel",
65
+ "model_module_version": "1.5.0",
66
+ "state": {
67
+ "_dom_classes": [],
68
+ "_model_module": "@jupyter-widgets/controls",
69
+ "_model_module_version": "1.5.0",
70
+ "_model_name": "FloatProgressModel",
71
+ "_view_count": null,
72
+ "_view_module": "@jupyter-widgets/controls",
73
+ "_view_module_version": "1.5.0",
74
+ "_view_name": "ProgressView",
75
+ "bar_style": "success",
76
+ "description": "",
77
+ "description_tooltip": null,
78
+ "layout": "IPY_MODEL_ab753d3138414937b882712412a14550",
79
+ "max": 3,
80
+ "min": 0,
81
+ "orientation": "horizontal",
82
+ "style": "IPY_MODEL_7c265c9ce1bf46638dc42beb01b4bb31",
83
+ "value": 3
84
+ }
85
+ },
86
+ "419f9b313a5e4fb5b5a5b1c8db30cd27": {
87
+ "model_module": "@jupyter-widgets/controls",
88
+ "model_name": "HTMLModel",
89
+ "model_module_version": "1.5.0",
90
+ "state": {
91
+ "_dom_classes": [],
92
+ "_model_module": "@jupyter-widgets/controls",
93
+ "_model_module_version": "1.5.0",
94
+ "_model_name": "HTMLModel",
95
+ "_view_count": null,
96
+ "_view_module": "@jupyter-widgets/controls",
97
+ "_view_module_version": "1.5.0",
98
+ "_view_name": "HTMLView",
99
+ "description": "",
100
+ "description_tooltip": null,
101
+ "layout": "IPY_MODEL_e4c9fe5abf9f47498a249ba80e1b47fb",
102
+ "placeholder": "​",
103
+ "style": "IPY_MODEL_cc23e8d656e844309e35dfba411cd75c",
104
+ "value": " 3/3 [01:08<00:00, 22.20s/it]"
105
+ }
106
+ },
107
+ "39f7db24cde842828d2b2f10b947c9b3": {
108
+ "model_module": "@jupyter-widgets/base",
109
+ "model_name": "LayoutModel",
110
+ "model_module_version": "1.2.0",
111
+ "state": {
112
+ "_model_module": "@jupyter-widgets/base",
113
+ "_model_module_version": "1.2.0",
114
+ "_model_name": "LayoutModel",
115
+ "_view_count": null,
116
+ "_view_module": "@jupyter-widgets/base",
117
+ "_view_module_version": "1.2.0",
118
+ "_view_name": "LayoutView",
119
+ "align_content": null,
120
+ "align_items": null,
121
+ "align_self": null,
122
+ "border": null,
123
+ "bottom": null,
124
+ "display": null,
125
+ "flex": null,
126
+ "flex_flow": null,
127
+ "grid_area": null,
128
+ "grid_auto_columns": null,
129
+ "grid_auto_flow": null,
130
+ "grid_auto_rows": null,
131
+ "grid_column": null,
132
+ "grid_gap": null,
133
+ "grid_row": null,
134
+ "grid_template_areas": null,
135
+ "grid_template_columns": null,
136
+ "grid_template_rows": null,
137
+ "height": null,
138
+ "justify_content": null,
139
+ "justify_items": null,
140
+ "left": null,
141
+ "margin": null,
142
+ "max_height": null,
143
+ "max_width": null,
144
+ "min_height": null,
145
+ "min_width": null,
146
+ "object_fit": null,
147
+ "object_position": null,
148
+ "order": null,
149
+ "overflow": null,
150
+ "overflow_x": null,
151
+ "overflow_y": null,
152
+ "padding": null,
153
+ "right": null,
154
+ "top": null,
155
+ "visibility": null,
156
+ "width": null
157
+ }
158
+ },
159
+ "2d0f034676124ae68c8304249b50105a": {
160
+ "model_module": "@jupyter-widgets/base",
161
+ "model_name": "LayoutModel",
162
+ "model_module_version": "1.2.0",
163
+ "state": {
164
+ "_model_module": "@jupyter-widgets/base",
165
+ "_model_module_version": "1.2.0",
166
+ "_model_name": "LayoutModel",
167
+ "_view_count": null,
168
+ "_view_module": "@jupyter-widgets/base",
169
+ "_view_module_version": "1.2.0",
170
+ "_view_name": "LayoutView",
171
+ "align_content": null,
172
+ "align_items": null,
173
+ "align_self": null,
174
+ "border": null,
175
+ "bottom": null,
176
+ "display": null,
177
+ "flex": null,
178
+ "flex_flow": null,
179
+ "grid_area": null,
180
+ "grid_auto_columns": null,
181
+ "grid_auto_flow": null,
182
+ "grid_auto_rows": null,
183
+ "grid_column": null,
184
+ "grid_gap": null,
185
+ "grid_row": null,
186
+ "grid_template_areas": null,
187
+ "grid_template_columns": null,
188
+ "grid_template_rows": null,
189
+ "height": null,
190
+ "justify_content": null,
191
+ "justify_items": null,
192
+ "left": null,
193
+ "margin": null,
194
+ "max_height": null,
195
+ "max_width": null,
196
+ "min_height": null,
197
+ "min_width": null,
198
+ "object_fit": null,
199
+ "object_position": null,
200
+ "order": null,
201
+ "overflow": null,
202
+ "overflow_x": null,
203
+ "overflow_y": null,
204
+ "padding": null,
205
+ "right": null,
206
+ "top": null,
207
+ "visibility": null,
208
+ "width": null
209
+ }
210
+ },
211
+ "5e30295db2ed4bd1803070be6e39020a": {
212
+ "model_module": "@jupyter-widgets/controls",
213
+ "model_name": "DescriptionStyleModel",
214
+ "model_module_version": "1.5.0",
215
+ "state": {
216
+ "_model_module": "@jupyter-widgets/controls",
217
+ "_model_module_version": "1.5.0",
218
+ "_model_name": "DescriptionStyleModel",
219
+ "_view_count": null,
220
+ "_view_module": "@jupyter-widgets/base",
221
+ "_view_module_version": "1.2.0",
222
+ "_view_name": "StyleView",
223
+ "description_width": ""
224
+ }
225
+ },
226
+ "ab753d3138414937b882712412a14550": {
227
+ "model_module": "@jupyter-widgets/base",
228
+ "model_name": "LayoutModel",
229
+ "model_module_version": "1.2.0",
230
+ "state": {
231
+ "_model_module": "@jupyter-widgets/base",
232
+ "_model_module_version": "1.2.0",
233
+ "_model_name": "LayoutModel",
234
+ "_view_count": null,
235
+ "_view_module": "@jupyter-widgets/base",
236
+ "_view_module_version": "1.2.0",
237
+ "_view_name": "LayoutView",
238
+ "align_content": null,
239
+ "align_items": null,
240
+ "align_self": null,
241
+ "border": null,
242
+ "bottom": null,
243
+ "display": null,
244
+ "flex": null,
245
+ "flex_flow": null,
246
+ "grid_area": null,
247
+ "grid_auto_columns": null,
248
+ "grid_auto_flow": null,
249
+ "grid_auto_rows": null,
250
+ "grid_column": null,
251
+ "grid_gap": null,
252
+ "grid_row": null,
253
+ "grid_template_areas": null,
254
+ "grid_template_columns": null,
255
+ "grid_template_rows": null,
256
+ "height": null,
257
+ "justify_content": null,
258
+ "justify_items": null,
259
+ "left": null,
260
+ "margin": null,
261
+ "max_height": null,
262
+ "max_width": null,
263
+ "min_height": null,
264
+ "min_width": null,
265
+ "object_fit": null,
266
+ "object_position": null,
267
+ "order": null,
268
+ "overflow": null,
269
+ "overflow_x": null,
270
+ "overflow_y": null,
271
+ "padding": null,
272
+ "right": null,
273
+ "top": null,
274
+ "visibility": null,
275
+ "width": null
276
+ }
277
+ },
278
+ "7c265c9ce1bf46638dc42beb01b4bb31": {
279
+ "model_module": "@jupyter-widgets/controls",
280
+ "model_name": "ProgressStyleModel",
281
+ "model_module_version": "1.5.0",
282
+ "state": {
283
+ "_model_module": "@jupyter-widgets/controls",
284
+ "_model_module_version": "1.5.0",
285
+ "_model_name": "ProgressStyleModel",
286
+ "_view_count": null,
287
+ "_view_module": "@jupyter-widgets/base",
288
+ "_view_module_version": "1.2.0",
289
+ "_view_name": "StyleView",
290
+ "bar_color": null,
291
+ "description_width": ""
292
+ }
293
+ },
294
+ "e4c9fe5abf9f47498a249ba80e1b47fb": {
295
+ "model_module": "@jupyter-widgets/base",
296
+ "model_name": "LayoutModel",
297
+ "model_module_version": "1.2.0",
298
+ "state": {
299
+ "_model_module": "@jupyter-widgets/base",
300
+ "_model_module_version": "1.2.0",
301
+ "_model_name": "LayoutModel",
302
+ "_view_count": null,
303
+ "_view_module": "@jupyter-widgets/base",
304
+ "_view_module_version": "1.2.0",
305
+ "_view_name": "LayoutView",
306
+ "align_content": null,
307
+ "align_items": null,
308
+ "align_self": null,
309
+ "border": null,
310
+ "bottom": null,
311
+ "display": null,
312
+ "flex": null,
313
+ "flex_flow": null,
314
+ "grid_area": null,
315
+ "grid_auto_columns": null,
316
+ "grid_auto_flow": null,
317
+ "grid_auto_rows": null,
318
+ "grid_column": null,
319
+ "grid_gap": null,
320
+ "grid_row": null,
321
+ "grid_template_areas": null,
322
+ "grid_template_columns": null,
323
+ "grid_template_rows": null,
324
+ "height": null,
325
+ "justify_content": null,
326
+ "justify_items": null,
327
+ "left": null,
328
+ "margin": null,
329
+ "max_height": null,
330
+ "max_width": null,
331
+ "min_height": null,
332
+ "min_width": null,
333
+ "object_fit": null,
334
+ "object_position": null,
335
+ "order": null,
336
+ "overflow": null,
337
+ "overflow_x": null,
338
+ "overflow_y": null,
339
+ "padding": null,
340
+ "right": null,
341
+ "top": null,
342
+ "visibility": null,
343
+ "width": null
344
+ }
345
+ },
346
+ "cc23e8d656e844309e35dfba411cd75c": {
347
+ "model_module": "@jupyter-widgets/controls",
348
+ "model_name": "DescriptionStyleModel",
349
+ "model_module_version": "1.5.0",
350
+ "state": {
351
+ "_model_module": "@jupyter-widgets/controls",
352
+ "_model_module_version": "1.5.0",
353
+ "_model_name": "DescriptionStyleModel",
354
+ "_view_count": null,
355
+ "_view_module": "@jupyter-widgets/base",
356
+ "_view_module_version": "1.2.0",
357
+ "_view_name": "StyleView",
358
+ "description_width": ""
359
+ }
360
+ }
361
+ }
362
+ }
363
+ },
364
+ "cells": [
365
+ {
366
+ "cell_type": "code",
367
+ "execution_count": 1,
368
+ "metadata": {
369
+ "colab": {
370
+ "base_uri": "https://localhost:8080/"
371
+ },
372
+ "id": "9nImld6CECvz",
373
+ "outputId": "533ce939-be31-4f83-d6d2-09db03a02e25"
374
+ },
375
+ "outputs": [
376
+ {
377
+ "output_type": "stream",
378
+ "name": "stdout",
379
+ "text": [
380
+ " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
381
+ " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
382
+ " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n"
383
+ ]
384
+ }
385
+ ],
386
+ "source": [
387
+ "!pip install -q -U transformers==4.37.2\n",
388
+ "!pip install -q bitsandbytes==0.41.3 accelerate==0.25.0\n",
389
+ "!pip install -q git+https://github.com/openai/whisper.git\n",
390
+ "!pip install -q gradio\n",
391
+ "!pip install -q gTTS"
392
+ ]
393
+ },
394
+ {
395
+ "cell_type": "code",
396
+ "source": [
397
+ "import torch\n",
398
+ "from transformers import BitsAndBytesConfig, pipeline"
399
+ ],
400
+ "metadata": {
401
+ "id": "c5xSk8MzFUPj"
402
+ },
403
+ "execution_count": 2,
404
+ "outputs": []
405
+ },
406
+ {
407
+ "cell_type": "code",
408
+ "source": [
409
+ "quantization_config = BitsAndBytesConfig(\n",
410
+ " load_in_4bit=True,\n",
411
+ " bnb_4bit_compute_dtype=torch.float16\n",
412
+ "\n",
413
+ ")"
414
+ ],
415
+ "metadata": {
416
+ "id": "97Hub2vjHdF1"
417
+ },
418
+ "execution_count": 3,
419
+ "outputs": []
420
+ },
421
+ {
422
+ "cell_type": "code",
423
+ "source": [
424
+ "model_id = 'llava-hf/llava-1.5-7b-hf'"
425
+ ],
426
+ "metadata": {
427
+ "id": "ZeZ3wd8zHvfd"
428
+ },
429
+ "execution_count": 4,
430
+ "outputs": []
431
+ },
432
+ {
433
+ "cell_type": "code",
434
+ "source": [
435
+ "pipe = pipeline(\"image-to-text\",\n",
436
+ " model=model_id,\n",
437
+ " model_kwargs={\"quantization_config\": quantization_config})"
438
+ ],
439
+ "metadata": {
440
+ "colab": {
441
+ "base_uri": "https://localhost:8080/",
442
+ "height": 190,
443
+ "referenced_widgets": [
444
+ "2f36b8ed6b5f47c9beffb251660ab817",
445
+ "dd79591e26d54d749f84339205484e50",
446
+ "6b4a398fb55d4b509188d16cd66615ed",
447
+ "419f9b313a5e4fb5b5a5b1c8db30cd27",
448
+ "39f7db24cde842828d2b2f10b947c9b3",
449
+ "2d0f034676124ae68c8304249b50105a",
450
+ "5e30295db2ed4bd1803070be6e39020a",
451
+ "ab753d3138414937b882712412a14550",
452
+ "7c265c9ce1bf46638dc42beb01b4bb31",
453
+ "e4c9fe5abf9f47498a249ba80e1b47fb",
454
+ "cc23e8d656e844309e35dfba411cd75c"
455
+ ]
456
+ },
457
+ "id": "DUIG1iTdH4Bo",
458
+ "outputId": "b671f177-6ff7-4b89-a560-e8c75a096c12"
459
+ },
460
+ "execution_count": 5,
461
+ "outputs": [
462
+ {
463
+ "output_type": "stream",
464
+ "name": "stderr",
465
+ "text": [
466
+ "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: \n",
467
+ "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
468
+ "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
469
+ "You will be able to reuse this secret in all of your notebooks.\n",
470
+ "Please note that authentication is recommended but still optional to access public models or datasets.\n",
471
+ " warnings.warn(\n"
472
+ ]
473
+ },
474
+ {
475
+ "output_type": "display_data",
476
+ "data": {
477
+ "text/plain": [
478
+ "Loading checkpoint shards: 0%| | 0/3 [00:00<?, ?it/s]"
479
+ ],
480
+ "application/vnd.jupyter.widget-view+json": {
481
+ "version_major": 2,
482
+ "version_minor": 0,
483
+ "model_id": "2f36b8ed6b5f47c9beffb251660ab817"
484
+ }
485
+ },
486
+ "metadata": {}
487
+ },
488
+ {
489
+ "output_type": "stream",
490
+ "name": "stderr",
491
+ "text": [
492
+ "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
493
+ ]
494
+ }
495
+ ]
496
+ },
497
+ {
498
+ "cell_type": "code",
499
+ "source": [
500
+ "import whisper\n",
501
+ "import gradio as gr\n",
502
+ "import time\n",
503
+ "import warnings\n",
504
+ "import os\n",
505
+ "from gtts import gTTS\n",
506
+ "from PIL import Image\n",
507
+ "\n",
508
+ "import nltk\n",
509
+ "nltk.download('punkt')\n",
510
+ "from nltk import sent_tokenize"
511
+ ],
512
+ "metadata": {
513
+ "colab": {
514
+ "base_uri": "https://localhost:8080/"
515
+ },
516
+ "id": "VuFVn-5-M4CX",
517
+ "outputId": "b6a4e647-281e-4155-f4e2-597f00e84f4a"
518
+ },
519
+ "execution_count": 6,
520
+ "outputs": [
521
+ {
522
+ "output_type": "stream",
523
+ "name": "stderr",
524
+ "text": [
525
+ "[nltk_data] Downloading package punkt to /root/nltk_data...\n",
526
+ "[nltk_data] Package punkt is already up-to-date!\n"
527
+ ]
528
+ }
529
+ ]
530
+ },
531
+ {
532
+ "cell_type": "code",
533
+ "source": [
534
+ "max_new_tokens = 250\n",
535
+ "prompt_instructions = \"\"\"Describe the image using as much detail as possible,\n",
536
+ "is it a painting, a photograph, what colors are predominant,\n",
537
+ "what is the image about?\n",
538
+ "\"\"\""
539
+ ],
540
+ "metadata": {
541
+ "id": "ZSAGF7q4NzgT"
542
+ },
543
+ "execution_count": 7,
544
+ "outputs": []
545
+ },
546
+ {
547
+ "cell_type": "code",
548
+ "source": [
549
+ "warnings.filterwarnings(\"ignore\")"
550
+ ],
551
+ "metadata": {
552
+ "id": "QhE1zJZ6PiVV"
553
+ },
554
+ "execution_count": 7,
555
+ "outputs": []
556
+ },
557
+ {
558
+ "cell_type": "code",
559
+ "source": [
560
+ "import numpy as np"
561
+ ],
562
+ "metadata": {
563
+ "id": "W49-1pJyPwyP"
564
+ },
565
+ "execution_count": 8,
566
+ "outputs": []
567
+ },
568
+ {
569
+ "cell_type": "code",
570
+ "source": [
571
+ "DEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
572
+ "print(DEVICE)"
573
+ ],
574
+ "metadata": {
575
+ "colab": {
576
+ "base_uri": "https://localhost:8080/"
577
+ },
578
+ "id": "x8FPU6l7Pz-L",
579
+ "outputId": "a9fe1aad-8777-48c7-9abc-27841d22793f"
580
+ },
581
+ "execution_count": 9,
582
+ "outputs": [
583
+ {
584
+ "output_type": "stream",
585
+ "name": "stdout",
586
+ "text": [
587
+ "cuda\n"
588
+ ]
589
+ }
590
+ ]
591
+ },
592
+ {
593
+ "cell_type": "code",
594
+ "source": [
595
+ "model = whisper.load_model(\"medium\",device=DEVICE)"
596
+ ],
597
+ "metadata": {
598
+ "id": "Fz0M4kZZP_kA"
599
+ },
600
+ "execution_count": 10,
601
+ "outputs": []
602
+ },
603
+ {
604
+ "cell_type": "code",
605
+ "source": [
606
+ "model = whisper.load_model(\"medium\", device=DEVICE)\n",
607
+ "print(\n",
608
+ " f\"Model is {'multilingual' if model.is_multilingual else 'English-only'} \"\n",
609
+ " f\"and has {sum(np.prod(p.shape) for p in model.parameters()):,} parameters.\"\n",
610
+ ")"
611
+ ],
612
+ "metadata": {
613
+ "colab": {
614
+ "base_uri": "https://localhost:8080/"
615
+ },
616
+ "id": "b9Uw6SQiQszE",
617
+ "outputId": "0db48163-babe-4731-9282-ea880f0e3a00"
618
+ },
619
+ "execution_count": 11,
620
+ "outputs": [
621
+ {
622
+ "output_type": "stream",
623
+ "name": "stdout",
624
+ "text": [
625
+ "Model is multilingual and has 762,321,920 parameters.\n"
626
+ ]
627
+ }
628
+ ]
629
+ },
630
+ {
631
+ "cell_type": "code",
632
+ "source": [
633
+ "import datetime\n",
634
+ "import os\n",
635
+ "\n",
636
+ "\n",
637
+ "## Logger file\n",
638
+ "tstamp = datetime.datetime.now()\n",
639
+ "tstamp = str(tstamp).replace(' ','_')\n",
640
+ "logfile = f'{tstamp}_log.txt'\n",
641
+ "def writehistory(text):\n",
642
+ " with open(logfile, 'a', encoding='utf-8') as f:\n",
643
+ " f.write(text)\n",
644
+ " f.write('\\n')\n",
645
+ " f.close()\n",
646
+ "\n"
647
+ ],
648
+ "metadata": {
649
+ "id": "fIJ7k5rCjvgW"
650
+ },
651
+ "execution_count": 12,
652
+ "outputs": []
653
+ },
654
+ {
655
+ "cell_type": "code",
656
+ "source": [
657
+ "import re\n",
658
+ "import requests\n",
659
+ "from PIL import Image\n",
660
+ "\n",
661
+ "def img2txt(input_text, input_image):\n",
662
+ "\n",
663
+ " # load the image\n",
664
+ " image = Image.open(input_image)\n",
665
+ "\n",
666
+ " writehistory(f\"Input text: {input_text} - Type: {type(input_text)} - Dir: {dir(input_text)}\")\n",
667
+ " if type(input_text) == tuple:\n",
668
+ " prompt_instructions = \"\"\"\n",
669
+ " Describe the image using as much detail as possible.You are a helpful ai assistant who is able to answer all questions regarding the image in detail and what it is all about.\n",
670
+ "\n",
671
+ " \"\"\"\n",
672
+ " else:\n",
673
+ " prompt_instructions = \"\"\"\n",
674
+ " Act as an expert in imagery descriptive analysis, using as much detail as possible from the image, respond to the following prompt:\n",
675
+ " \"\"\" + input_text\n",
676
+ "\n",
677
+ " writehistory(f\"prompt_instructions: {prompt_instructions}\")\n",
678
+ " prompt = \"USER: <image>\\n\" + prompt_instructions + \"\\nAssistant:\"\n",
679
+ " outputs = pipe(image,prompt=prompt, generate_kwargs={\"max_new_tokens\": 250})\n",
680
+ "\n",
681
+ " if outputs is not None and len(outputs[0][\"generated_text\"])>0:\n",
682
+ " match = re.search(r'Assistant:\\s*(.*)',outputs[0][\"generated_text\"])\n",
683
+ " if match:\n",
684
+ " reply = match.group(1)\n",
685
+ " else:\n",
686
+ " reply = \"no response\"\n",
687
+ " else:\n",
688
+ " reply = \"no response generated\"\n",
689
+ " return reply"
690
+ ],
691
+ "metadata": {
692
+ "id": "-XBVEZhvjw-y"
693
+ },
694
+ "execution_count": 13,
695
+ "outputs": []
696
+ },
697
+ {
698
+ "cell_type": "code",
699
+ "source": [
700
+ "def transcribe(audio):\n",
701
+ "\n",
702
+ " # Check if the audio input is None or empty\n",
703
+ " if audio is None or audio == '':\n",
704
+ " return ('','',None) # Return empty strings and None audio file\n",
705
+ "\n",
706
+ " # language = 'en'\n",
707
+ "\n",
708
+ " audio = whisper.load_audio(audio)\n",
709
+ " audio = whisper.pad_or_trim(audio)\n",
710
+ "\n",
711
+ " mel = whisper.log_mel_spectrogram(audio).to(model.device)\n",
712
+ "\n",
713
+ " _, probs = model.detect_language(mel)\n",
714
+ "\n",
715
+ " options = whisper.DecodingOptions()\n",
716
+ " result = whisper.decode(model, mel, options)\n",
717
+ " result_text = result.text\n",
718
+ "\n",
719
+ " return result_text"
720
+ ],
721
+ "metadata": {
722
+ "id": "-lo6sMtOmInA"
723
+ },
724
+ "execution_count": 14,
725
+ "outputs": []
726
+ },
727
+ {
728
+ "cell_type": "code",
729
+ "source": [
730
+ "\n",
731
+ "def text_to_speech(text, file_path):\n",
732
+ " language = 'en'\n",
733
+ "\n",
734
+ " audioobj = gTTS(text = text,\n",
735
+ " lang = language,\n",
736
+ " slow = False)\n",
737
+ "\n",
738
+ " audioobj.save(file_path)\n",
739
+ "\n",
740
+ " return file_path"
741
+ ],
742
+ "metadata": {
743
+ "id": "VAK4GnHqmMwW"
744
+ },
745
+ "execution_count": 15,
746
+ "outputs": []
747
+ },
748
+ {
749
+ "cell_type": "code",
750
+ "source": [
751
+ "!ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t 10 -q:a 9 -acodec libmp3lame Temp.mp3"
752
+ ],
753
+ "metadata": {
754
+ "colab": {
755
+ "base_uri": "https://localhost:8080/"
756
+ },
757
+ "id": "nC7EtQ1NmPwr",
758
+ "outputId": "95844e73-f625-45c1-dd4b-a8ffab0b61d9"
759
+ },
760
+ "execution_count": 17,
761
+ "outputs": [
762
+ {
763
+ "output_type": "stream",
764
+ "name": "stdout",
765
+ "text": [
766
+ "ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers\n",
767
+ " built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)\n",
768
+ " configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared\n",
769
+ " libavutil 56. 70.100 / 56. 70.100\n",
770
+ " libavcodec 58.134.100 / 58.134.100\n",
771
+ " libavformat 58. 76.100 / 58. 76.100\n",
772
+ " libavdevice 58. 13.100 / 58. 13.100\n",
773
+ " libavfilter 7.110.100 / 7.110.100\n",
774
+ " libswscale 5. 9.100 / 5. 9.100\n",
775
+ " libswresample 3. 9.100 / 3. 9.100\n",
776
+ " libpostproc 55. 9.100 / 55. 9.100\n",
777
+ "Input #0, lavfi, from 'anullsrc=r=44100:cl=mono':\n",
778
+ " Duration: N/A, start: 0.000000, bitrate: 352 kb/s\n",
779
+ " Stream #0:0: Audio: pcm_u8, 44100 Hz, mono, u8, 352 kb/s\n",
780
+ "Stream mapping:\n",
781
+ " Stream #0:0 -> #0:0 (pcm_u8 (native) -> mp3 (libmp3lame))\n",
782
+ "Press [q] to stop, [?] for help\n",
783
+ "Output #0, mp3, to 'Temp.mp3':\n",
784
+ " Metadata:\n",
785
+ " TSSE : Lavf58.76.100\n",
786
+ " Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p\n",
787
+ " Metadata:\n",
788
+ " encoder : Lavc58.134.100 libmp3lame\n",
789
+ "size= 0kB time=00:00:00.00 bitrate=N/A speed=N/A \rsize= 39kB time=00:00:09.97 bitrate= 32.2kbits/s speed= 107x \n",
790
+ "video:0kB audio:39kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.568409%\n"
791
+ ]
792
+ }
793
+ ]
794
+ },
795
+ {
796
+ "cell_type": "code",
797
+ "source": [
798
+ "import gradio as gr\n",
799
+ "import base64\n",
800
+ "import os\n",
801
+ "\n",
802
+ "# A function to handle audio and image inputs\n",
803
+ "def process_inputs(audio_path, image_path):\n",
804
+ " # Process the audio file (assuming this is handled by a function called 'transcribe')\n",
805
+ " speech_to_text_output = transcribe(audio_path)\n",
806
+ "\n",
807
+ " # Handle the image input\n",
808
+ " if image_path:\n",
809
+ " chatgpt_output = img2txt(speech_to_text_output, image_path)\n",
810
+ " else:\n",
811
+ " chatgpt_output = \"No image provided.\"\n",
812
+ "\n",
813
+ " # Assuming 'transcribe' also returns the path to a processed audio file\n",
814
+ " processed_audio_path = text_to_speech(chatgpt_output, \"Temp.mp3\") # Replace with actual path if different\n",
815
+ "\n",
816
+ " return speech_to_text_output, chatgpt_output, processed_audio_path\n",
817
+ "\n",
818
+ "# Create the interface\n",
819
+ "iface = gr.Interface(\n",
820
+ " fn=process_inputs,\n",
821
+ " inputs=[\n",
822
+ " gr.Audio(sources=[\"microphone\"], type=\"filepath\"),\n",
823
+ " gr.Image(type=\"filepath\")\n",
824
+ " ],\n",
825
+ " outputs=[\n",
826
+ " gr.Textbox(label=\"Speech to Text\"),\n",
827
+ " gr.Textbox(label=\"ChatGPT Output\"),\n",
828
+ " gr.Audio(\"Temp.mp3\")\n",
829
+ " ],\n",
830
+ " title=\"Learn OpenAI Whisper: Image processing with Whisper and Llava\",\n",
831
+ " description=\"Upload an image and interact via voice input and audio response.\"\n",
832
+ ")\n",
833
+ "\n",
834
+ "# Launch the interface\n",
835
+ "iface.launch(debug=True)"
836
+ ],
837
+ "metadata": {
838
+ "colab": {
839
+ "base_uri": "https://localhost:8080/",
840
+ "height": 1000
841
+ },
842
+ "id": "wdGtBi3QmV4L",
843
+ "outputId": "267c123e-2f0f-4bed-be0b-3a9ddb83490d"
844
+ },
845
+ "execution_count": null,
846
+ "outputs": [
847
+ {
848
+ "metadata": {
849
+ "tags": null
850
+ },
851
+ "name": "stdout",
852
+ "output_type": "stream",
853
+ "text": [
854
+ "Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n",
855
+ "\n",
856
+ "Colab notebook detected. This cell will run indefinitely so that you can see errors and logs. To turn off, set debug=False in launch().\n",
857
+ "Running on public URL: https://6d13e2910598c25aef.gradio.live\n",
858
+ "\n",
859
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
860
+ ]
861
+ },
862
+ {
863
+ "data": {
864
+ "text/html": [
865
+ "<div><iframe src=\"https://6d13e2910598c25aef.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
866
+ ],
867
+ "text/plain": [
868
+ "<IPython.core.display.HTML object>"
869
+ ]
870
+ },
871
+ "metadata": {},
872
+ "output_type": "display_data"
873
+ },
874
+ {
875
+ "metadata": {
876
+ "tags": null
877
+ },
878
+ "name": "stderr",
879
+ "output_type": "stream",
880
+ "text": [
881
+ "ERROR: Exception in ASGI application\n",
882
+ "Traceback (most recent call last):\n",
883
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
884
+ " result = await app( # type: ignore[func-returns-value]\n",
885
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
886
+ " return await self.app(scope, receive, send)\n",
887
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
888
+ " await super().__call__(scope, receive, send)\n",
889
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
890
+ " await self.middleware_stack(scope, receive, send)\n",
891
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
892
+ " raise exc\n",
893
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
894
+ " await self.app(scope, receive, _send)\n",
895
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
896
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
897
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
898
+ " await self.app(scope, receive, send)\n",
899
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
900
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
901
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
902
+ " raise exc\n",
903
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
904
+ " await app(scope, receive, sender)\n",
905
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
906
+ " await self.middleware_stack(scope, receive, send)\n",
907
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
908
+ " await route.handle(scope, receive, send)\n",
909
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
910
+ " await self.app(scope, receive, send)\n",
911
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
912
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
913
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
914
+ " raise exc\n",
915
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
916
+ " await app(scope, receive, sender)\n",
917
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
918
+ " response = await func(request)\n",
919
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
920
+ " raw_response = await run_endpoint_function(\n",
921
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
922
+ " return await dependant.call(**values)\n",
923
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
924
+ " form = await multipart_parser.parse()\n",
925
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
926
+ " async for chunk in self.stream:\n",
927
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
928
+ " raise ClientDisconnect()\n",
929
+ "starlette.requests.ClientDisconnect\n",
930
+ "ERROR: Exception in ASGI application\n",
931
+ "Traceback (most recent call last):\n",
932
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
933
+ " result = await app( # type: ignore[func-returns-value]\n",
934
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
935
+ " return await self.app(scope, receive, send)\n",
936
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
937
+ " await super().__call__(scope, receive, send)\n",
938
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
939
+ " await self.middleware_stack(scope, receive, send)\n",
940
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
941
+ " raise exc\n",
942
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
943
+ " await self.app(scope, receive, _send)\n",
944
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
945
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
946
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
947
+ " await self.app(scope, receive, send)\n",
948
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
949
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
950
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
951
+ " raise exc\n",
952
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
953
+ " await app(scope, receive, sender)\n",
954
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
955
+ " await self.middleware_stack(scope, receive, send)\n",
956
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
957
+ " await route.handle(scope, receive, send)\n",
958
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
959
+ " await self.app(scope, receive, send)\n",
960
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
961
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
962
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
963
+ " raise exc\n",
964
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
965
+ " await app(scope, receive, sender)\n",
966
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
967
+ " response = await func(request)\n",
968
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
969
+ " raw_response = await run_endpoint_function(\n",
970
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
971
+ " return await dependant.call(**values)\n",
972
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
973
+ " form = await multipart_parser.parse()\n",
974
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
975
+ " async for chunk in self.stream:\n",
976
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
977
+ " raise ClientDisconnect()\n",
978
+ "starlette.requests.ClientDisconnect\n",
979
+ "ERROR: Exception in ASGI application\n",
980
+ "Traceback (most recent call last):\n",
981
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
982
+ " result = await app( # type: ignore[func-returns-value]\n",
983
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
984
+ " return await self.app(scope, receive, send)\n",
985
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
986
+ " await super().__call__(scope, receive, send)\n",
987
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
988
+ " await self.middleware_stack(scope, receive, send)\n",
989
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
990
+ " raise exc\n",
991
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
992
+ " await self.app(scope, receive, _send)\n",
993
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
994
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
995
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
996
+ " await self.app(scope, receive, send)\n",
997
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
998
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
999
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1000
+ " raise exc\n",
1001
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1002
+ " await app(scope, receive, sender)\n",
1003
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
1004
+ " await self.middleware_stack(scope, receive, send)\n",
1005
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
1006
+ " await route.handle(scope, receive, send)\n",
1007
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
1008
+ " await self.app(scope, receive, send)\n",
1009
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
1010
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
1011
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1012
+ " raise exc\n",
1013
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1014
+ " await app(scope, receive, sender)\n",
1015
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
1016
+ " response = await func(request)\n",
1017
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
1018
+ " raw_response = await run_endpoint_function(\n",
1019
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
1020
+ " return await dependant.call(**values)\n",
1021
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
1022
+ " form = await multipart_parser.parse()\n",
1023
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
1024
+ " async for chunk in self.stream:\n",
1025
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
1026
+ " raise ClientDisconnect()\n",
1027
+ "starlette.requests.ClientDisconnect\n",
1028
+ "ERROR: Exception in ASGI application\n",
1029
+ "Traceback (most recent call last):\n",
1030
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
1031
+ " result = await app( # type: ignore[func-returns-value]\n",
1032
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
1033
+ " return await self.app(scope, receive, send)\n",
1034
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
1035
+ " await super().__call__(scope, receive, send)\n",
1036
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
1037
+ " await self.middleware_stack(scope, receive, send)\n",
1038
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
1039
+ " raise exc\n",
1040
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
1041
+ " await self.app(scope, receive, _send)\n",
1042
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
1043
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
1044
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
1045
+ " await self.app(scope, receive, send)\n",
1046
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
1047
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
1048
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1049
+ " raise exc\n",
1050
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1051
+ " await app(scope, receive, sender)\n",
1052
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
1053
+ " await self.middleware_stack(scope, receive, send)\n",
1054
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
1055
+ " await route.handle(scope, receive, send)\n",
1056
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
1057
+ " await self.app(scope, receive, send)\n",
1058
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
1059
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
1060
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1061
+ " raise exc\n",
1062
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1063
+ " await app(scope, receive, sender)\n",
1064
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
1065
+ " response = await func(request)\n",
1066
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
1067
+ " raw_response = await run_endpoint_function(\n",
1068
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
1069
+ " return await dependant.call(**values)\n",
1070
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
1071
+ " form = await multipart_parser.parse()\n",
1072
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
1073
+ " async for chunk in self.stream:\n",
1074
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
1075
+ " raise ClientDisconnect()\n",
1076
+ "starlette.requests.ClientDisconnect\n",
1077
+ "ERROR: Exception in ASGI application\n",
1078
+ "Traceback (most recent call last):\n",
1079
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
1080
+ " result = await app( # type: ignore[func-returns-value]\n",
1081
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
1082
+ " return await self.app(scope, receive, send)\n",
1083
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
1084
+ " await super().__call__(scope, receive, send)\n",
1085
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
1086
+ " await self.middleware_stack(scope, receive, send)\n",
1087
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
1088
+ " raise exc\n",
1089
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
1090
+ " await self.app(scope, receive, _send)\n",
1091
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
1092
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
1093
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
1094
+ " await self.app(scope, receive, send)\n",
1095
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
1096
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
1097
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1098
+ " raise exc\n",
1099
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1100
+ " await app(scope, receive, sender)\n",
1101
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
1102
+ " await self.middleware_stack(scope, receive, send)\n",
1103
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
1104
+ " await route.handle(scope, receive, send)\n",
1105
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
1106
+ " await self.app(scope, receive, send)\n",
1107
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
1108
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
1109
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1110
+ " raise exc\n",
1111
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1112
+ " await app(scope, receive, sender)\n",
1113
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
1114
+ " response = await func(request)\n",
1115
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
1116
+ " raw_response = await run_endpoint_function(\n",
1117
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
1118
+ " return await dependant.call(**values)\n",
1119
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
1120
+ " form = await multipart_parser.parse()\n",
1121
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
1122
+ " async for chunk in self.stream:\n",
1123
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
1124
+ " raise ClientDisconnect()\n",
1125
+ "starlette.requests.ClientDisconnect\n",
1126
+ "ERROR: Exception in ASGI application\n",
1127
+ "Traceback (most recent call last):\n",
1128
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
1129
+ " result = await app( # type: ignore[func-returns-value]\n",
1130
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
1131
+ " return await self.app(scope, receive, send)\n",
1132
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
1133
+ " await super().__call__(scope, receive, send)\n",
1134
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
1135
+ " await self.middleware_stack(scope, receive, send)\n",
1136
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
1137
+ " raise exc\n",
1138
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
1139
+ " await self.app(scope, receive, _send)\n",
1140
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
1141
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
1142
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
1143
+ " await self.app(scope, receive, send)\n",
1144
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
1145
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
1146
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1147
+ " raise exc\n",
1148
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1149
+ " await app(scope, receive, sender)\n",
1150
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
1151
+ " await self.middleware_stack(scope, receive, send)\n",
1152
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
1153
+ " await route.handle(scope, receive, send)\n",
1154
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
1155
+ " await self.app(scope, receive, send)\n",
1156
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
1157
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
1158
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1159
+ " raise exc\n",
1160
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1161
+ " await app(scope, receive, sender)\n",
1162
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
1163
+ " response = await func(request)\n",
1164
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
1165
+ " raw_response = await run_endpoint_function(\n",
1166
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
1167
+ " return await dependant.call(**values)\n",
1168
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
1169
+ " form = await multipart_parser.parse()\n",
1170
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
1171
+ " async for chunk in self.stream:\n",
1172
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
1173
+ " raise ClientDisconnect()\n",
1174
+ "starlette.requests.ClientDisconnect\n",
1175
+ "ERROR: Exception in ASGI application\n",
1176
+ "Traceback (most recent call last):\n",
1177
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n",
1178
+ " result = await app( # type: ignore[func-returns-value]\n",
1179
+ " File \"/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py\", line 69, in __call__\n",
1180
+ " return await self.app(scope, receive, send)\n",
1181
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/applications.py\", line 1054, in __call__\n",
1182
+ " await super().__call__(scope, receive, send)\n",
1183
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/applications.py\", line 123, in __call__\n",
1184
+ " await self.middleware_stack(scope, receive, send)\n",
1185
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 186, in __call__\n",
1186
+ " raise exc\n",
1187
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py\", line 164, in __call__\n",
1188
+ " await self.app(scope, receive, _send)\n",
1189
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 713, in __call__\n",
1190
+ " await self.simple_response(scope, receive, send, request_headers=headers)\n",
1191
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 729, in simple_response\n",
1192
+ " await self.app(scope, receive, send)\n",
1193
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py\", line 65, in __call__\n",
1194
+ " await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n",
1195
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1196
+ " raise exc\n",
1197
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1198
+ " await app(scope, receive, sender)\n",
1199
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 756, in __call__\n",
1200
+ " await self.middleware_stack(scope, receive, send)\n",
1201
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 776, in app\n",
1202
+ " await route.handle(scope, receive, send)\n",
1203
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 297, in handle\n",
1204
+ " await self.app(scope, receive, send)\n",
1205
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 77, in app\n",
1206
+ " await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n",
1207
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 64, in wrapped_app\n",
1208
+ " raise exc\n",
1209
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py\", line 53, in wrapped_app\n",
1210
+ " await app(scope, receive, sender)\n",
1211
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/routing.py\", line 72, in app\n",
1212
+ " response = await func(request)\n",
1213
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 278, in app\n",
1214
+ " raw_response = await run_endpoint_function(\n",
1215
+ " File \"/usr/local/lib/python3.10/dist-packages/fastapi/routing.py\", line 191, in run_endpoint_function\n",
1216
+ " return await dependant.call(**values)\n",
1217
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 1058, in upload_file\n",
1218
+ " form = await multipart_parser.parse()\n",
1219
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 597, in parse\n",
1220
+ " async for chunk in self.stream:\n",
1221
+ " File \"/usr/local/lib/python3.10/dist-packages/starlette/requests.py\", line 238, in stream\n",
1222
+ " raise ClientDisconnect()\n",
1223
+ "starlette.requests.ClientDisconnect\n"
1224
+ ]
1225
+ }
1226
+ ]
1227
+ }
1228
+ ]
1229
+ }