File size: 6,824 Bytes
ae09409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "β”Œβ”€ Modal Deprecation Warning (2025-02-06) ────────────────────────────────────┐\n",
      "β”‚ Using Python module paths will require using the -m flag in a future        β”‚\n",
      "β”‚ version of Modal.                                                           β”‚\n",
      "β”‚ Use `modal deploy -m classifier_modal` instead.                             β”‚\n",
      "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
      "β”Œβ”€ Modal Deprecation Warning (2025-01-15) ────────────────────────────────────┐\n",
      "β”‚ The `@modal.build` decorator is deprecated and will be removed in a future  β”‚\n",
      "β”‚ release.                                                                    β”‚\n",
      "β”‚                                                                             β”‚\n",
      "β”‚ We now recommend storing large assets (such as model weights) using a       β”‚\n",
      "β”‚ `modal.Volume` instead of writing them directly into the `modal.Image`      β”‚\n",
      "β”‚ filesystem. For other use cases we recommend using `Image.run_function`     β”‚\n",
      "β”‚ instead.                                                                    β”‚\n",
      "β”‚                                                                             β”‚\n",
      "β”‚ See https://modal.com/docs/guide/modal-1-0-migration for more information.  β”‚\n",
      "β”‚                                                                             β”‚\n",
      "β”‚ Source: c:\\LLM\\AccentDetector\\classifier_modal.py:12                        β”‚\n",
      "β”‚   @modal.build()                                                            β”‚\n",
      "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
      "- Creating objects...\n",
      "\\ Creating objects...\n",
      "└── - Creating mount c:\\LLM\\AccentDetector\\classifier_modal.py: Uploaded 0/1 \n",
      "    files\n",
      "/ Creating objects...\n",
      "└── | Creating mount c:\\LLM\\AccentDetector\\classifier_modal.py: Uploaded 0/1 \n",
      "    files\n",
      "\\ Creating objects...\n",
      "└── / Creating mount c:\\LLM\\AccentDetector\\classifier_modal.py: Uploaded 0/1 \n",
      "    files\n",
      "/ Creating objects...\n",
      "└── \\ Creating mount c:\\LLM\\AccentDetector\\classifier_modal.py: Finalizing \n",
      "    index of 1 files\n",
      "\\ Creating objects...\n",
      "β”œβ”€β”€ πŸ”¨ Created mount c:\\LLM\\AccentDetector\\classifier_modal.py\n",
      "└── πŸ”¨ Created function Accentizer.download_model.\n",
      "/ Creating objects...\n",
      "β”œβ”€β”€ πŸ”¨ Created mount c:\\LLM\\AccentDetector\\classifier_modal.py\n",
      "β”œβ”€β”€ πŸ”¨ Created function Accentizer.download_model.\n",
      "└── - Creating function Accentizer.*...\n",
      "\\ Creating objects...\n",
      "β”œβ”€β”€ πŸ”¨ Created mount c:\\LLM\\AccentDetector\\classifier_modal.py\n",
      "β”œβ”€β”€ πŸ”¨ Created function Accentizer.download_model.\n",
      "└── πŸ”¨ Created function Accentizer.*.\n",
      "\\ Creating objects...\n",
      "β”œβ”€β”€ πŸ”¨ Created mount c:\\LLM\\AccentDetector\\classifier_modal.py\n",
      "β”œβ”€β”€ πŸ”¨ Created function Accentizer.download_model.\n",
      "└── πŸ”¨ Created function Accentizer.*.\n",
      "\n",
      "βœ“ Created objects.\n",
      "β”œβ”€β”€ πŸ”¨ Created mount c:\\LLM\\AccentDetector\\classifier_modal.py\n",
      "β”œβ”€β”€ πŸ”¨ Created function Accentizer.download_model.\n",
      "└── πŸ”¨ Created function Accentizer.*.\n",
      "βœ“ App deployed in 2.520s! πŸŽ‰\n",
      "\n",
      "View Deployment: \n",
      "https://modal.com/apps/djallelbrahmia/main/deployed/ClassifierAudio\n"
     ]
    }
   ],
   "source": [
    "!modal deploy classifier_modal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Python312\\Lib\\asyncio\\events.py:88: DeprecationError: 2025-01-27: `modal.Cls.lookup` is deprecated and will be removed in a future release. It can be replaced with `modal.Cls.from_name`.\n",
      "\n",
      "See https://modal.com/docs/guide/modal-1-0-migration for more information.\n",
      "  self._context.run(self._callback, *self._args)\n",
      "C:\\Users\\dbrah\\AppData\\Local\\Temp\\ipykernel_62300\\1972719297.py:5: DeprecationError: 2025-01-13: Calling a method on an uninstantiated class will soon be deprecated; update your code to instantiate the class first, i.e.:\n",
      "Accentizer().classify instead of Accentizer.classify\n",
      "  result=Accentizer.classify.remote(link)\n"
     ]
    }
   ],
   "source": [
    "import modal\n",
    "import torch\n",
    "link=\"https://huggingface.co/Jzuluaga/accent-id-commonaccent_xlsr-en-english/resolve/main/data/malaysia_1.wav\"\n",
    "Accentizer = modal.Cls.lookup(\"ClassifierAudio\", \"Accentizer\")\n",
    "result=Accentizer.classify.remote(link)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'label': ['malaysia'],\n",
       " 'score': tensor([1.0000]),\n",
       " 'index': tensor([11]),\n",
       " 'out_prob': tensor([[1.1861e-06, 1.2054e-10, 5.3472e-11, 5.4380e-13, 2.0032e-15, 4.4907e-07,\n",
       "          6.3840e-15, 4.1447e-15, 6.7380e-18, 1.5645e-16, 2.8600e-14, 1.0000e+00,\n",
       "          9.1363e-11, 1.0672e-14, 2.5263e-11, 2.2510e-09]])}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}