modotte 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modotte-1.0.0/LICENSE +21 -0
- modotte-1.0.0/PKG-INFO +360 -0
- modotte-1.0.0/README.md +305 -0
- modotte-1.0.0/pyproject.toml +60 -0
- modotte-1.0.0/setup.cfg +4 -0
- modotte-1.0.0/src/modotte/AIRealNet.py +6 -0
- modotte-1.0.0/src/modotte/__init__.py +4 -0
- modotte-1.0.0/src/modotte/_common.py +108 -0
- modotte-1.0.0/src/modotte/_formats.py +180 -0
- modotte-1.0.0/src/modotte/audio.py +182 -0
- modotte-1.0.0/src/modotte/image.py +83 -0
- modotte-1.0.0/src/modotte.egg-info/PKG-INFO +360 -0
- modotte-1.0.0/src/modotte.egg-info/SOURCES.txt +16 -0
- modotte-1.0.0/src/modotte.egg-info/dependency_links.txt +1 -0
- modotte-1.0.0/src/modotte.egg-info/requires.txt +10 -0
- modotte-1.0.0/src/modotte.egg-info/top_level.txt +1 -0
- modotte-1.0.0/tests/test_audio.py +19 -0
- modotte-1.0.0/tests/test_image.py +13 -0
modotte-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 modotte-python
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
modotte-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modotte
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A universal Python package for accessing and using all AI models trained by Modotte.
|
|
5
|
+
Author: Sujal Rajpoot, Parvesh Rawal
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 modotte-python
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Repository, https://github.com/Modotte/modotte-python
|
|
29
|
+
Project-URL: Issues, https://github.com/Modotte/modotte-python/issues
|
|
30
|
+
Keywords: ai,artificial-intelligence,machine-learning,deep-learning,models,modotte,pytorch,transformers
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
41
|
+
Requires-Python: >=3.9
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: numpy
|
|
45
|
+
Requires-Dist: scipy
|
|
46
|
+
Requires-Dist: soundfile
|
|
47
|
+
Requires-Dist: pillow>=10.0
|
|
48
|
+
Requires-Dist: pillow-heif
|
|
49
|
+
Requires-Dist: cairosvg
|
|
50
|
+
Requires-Dist: av
|
|
51
|
+
Requires-Dist: torch
|
|
52
|
+
Requires-Dist: transformers
|
|
53
|
+
Requires-Dist: huggingface_hub
|
|
54
|
+
Dynamic: license-file
|
|
55
|
+
|
|
56
|
+
# modotte-python
|
|
57
|
+
|
|
58
|
+
A universal Python package for accessing and using all AI models trained by Modotte.
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
### Install from PyPI
|
|
63
|
+
|
|
64
|
+
Install the latest stable version directly from PyPI:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install modotte
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then import Modotte in your Python project:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from modotte import Audio, Image
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Upgrade to the latest version
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install --upgrade modotte
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Install from GitHub
|
|
85
|
+
|
|
86
|
+
You can also install the latest development version directly from GitHub:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install git+https://github.com/Modotte/modotte-python.git
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Clone the repository
|
|
93
|
+
|
|
94
|
+
If you want to develop or modify Modotte locally:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git clone https://github.com/Modotte/modotte-python.git
|
|
98
|
+
cd modotte-python
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Project Structure
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
modotte-python/
|
|
107
|
+
├── 📄 .gitignore
|
|
108
|
+
├── 📄 LICENSE
|
|
109
|
+
├── 📄 README.md
|
|
110
|
+
├── 📄 pyproject.toml
|
|
111
|
+
└── 📁 src/
|
|
112
|
+
└── 📁 modotte/
|
|
113
|
+
├── 📄 AIRealNet.py
|
|
114
|
+
├── 📄 __init__.py
|
|
115
|
+
├── 📄 _common.py ← internal
|
|
116
|
+
├── 📄 _formats.py ← internal
|
|
117
|
+
├── 📄 audio.py ← public API
|
|
118
|
+
└── 📄 image.py ← public API
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Hugging Face Token (Optional, Recommended)
|
|
122
|
+
|
|
123
|
+
The models are downloaded from the Hugging Face Hub on first use.
|
|
124
|
+
|
|
125
|
+
Without a token, you may see:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
Warning: You are sending unauthenticated requests to the HF Hub
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Unauthenticated requests are subject to lower rate limits. A free Hugging Face token can provide higher rate limits and more reliable downloads.
|
|
132
|
+
|
|
133
|
+
Create a token from:
|
|
134
|
+
|
|
135
|
+
https://huggingface.co/settings/tokens
|
|
136
|
+
|
|
137
|
+
There are three ways to provide it.
|
|
138
|
+
|
|
139
|
+
### 1. Pass the token directly
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from modotte import Audio, Image
|
|
143
|
+
|
|
144
|
+
detector = Audio(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
145
|
+
detector = Image(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 2. Set the `HF_TOKEN` environment variable
|
|
149
|
+
|
|
150
|
+
#### Windows PowerShell — current session
|
|
151
|
+
|
|
152
|
+
```powershell
|
|
153
|
+
$env:HF_TOKEN = "hf_xxxxxxxxxxxxxxxx"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Windows — permanent
|
|
157
|
+
|
|
158
|
+
```powershell
|
|
159
|
+
setx HF_TOKEN "hf_xxxxxxxxxxxxxxxx"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Open a new terminal after running `setx`.
|
|
163
|
+
|
|
164
|
+
#### macOS / Linux
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
export HF_TOKEN="hf_xxxxxxxxxxxxxxxx"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 3. Log in using the Hugging Face CLI
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
hf auth login
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
An explicit `hf_token=` argument takes priority over the `HF_TOKEN` environment variable.
|
|
177
|
+
|
|
178
|
+
The token is only used for downloading models. Modotte does not store or print your token.
|
|
179
|
+
|
|
180
|
+
Models are downloaded once and subsequently loaded from the local cache.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Audio Classification
|
|
185
|
+
|
|
186
|
+
Import the audio detector:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from modotte import Audio
|
|
190
|
+
|
|
191
|
+
detector = Audio()
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
On first use, Modotte checks for the model locally and downloads it if necessary.
|
|
195
|
+
|
|
196
|
+
You can optionally provide a Hugging Face token:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
detector = Audio(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Detect Bonafide / Real Audio
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
result = detector.predict("bonafide.wav", threshold=0.5)
|
|
206
|
+
|
|
207
|
+
print(result["label"])
|
|
208
|
+
print(result["confidence"])
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Detect Spoof / AI-Generated Audio
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
result = detector.predict("spoof.wav", threshold=0.5)
|
|
215
|
+
|
|
216
|
+
print(result["label"])
|
|
217
|
+
print(result["confidence"])
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The `threshold` parameter must be a float between `0.0` and `1.0`, inclusive.
|
|
221
|
+
|
|
222
|
+
Invalid types such as integers, strings, or booleans raise `TypeError`.
|
|
223
|
+
|
|
224
|
+
Values outside the range `0.0`–`1.0` raise `ValueError`.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Image Classification
|
|
229
|
+
|
|
230
|
+
Import the image detector:
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from modotte import Image
|
|
234
|
+
|
|
235
|
+
detector = Image()
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
On first use, Modotte checks for the model locally and downloads it if necessary.
|
|
239
|
+
|
|
240
|
+
You can optionally provide a Hugging Face token:
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
detector = Image(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Run a prediction:
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
result = detector.predict("cat.jpg")
|
|
250
|
+
|
|
251
|
+
print(result["label"])
|
|
252
|
+
print(result["confidence"])
|
|
253
|
+
print(result["scores"])
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Example:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
{
|
|
260
|
+
"label": "real",
|
|
261
|
+
"confidence": 0.94,
|
|
262
|
+
"scores": {
|
|
263
|
+
"artificial": 0.06,
|
|
264
|
+
"real": 0.94
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`Modotte/AIRealNet` is a binary SwinV2 Tiny classifier:
|
|
270
|
+
|
|
271
|
+
* Class 0: AI-generated
|
|
272
|
+
* Class 1: Real human image
|
|
273
|
+
|
|
274
|
+
Both import styles are supported:
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from modotte import Audio, Image
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
and:
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
from modotte.AIRealNet import Audio, Image
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Supported file types
|
|
289
|
+
|
|
290
|
+
- **Audio:** MP3, WAV, AAC, FLAC, OGG, Opus, M4A, AIFF
|
|
291
|
+
- **Image:** JPG, JPEG, PNG, WebP, GIF, SVG, BMP, TIFF, AVIF, HEIC, HEIF
|
|
292
|
+
|
|
293
|
+
Other extensions raise `ValueError`. WAV/FLAC/OGG/Opus/AIFF/MP3 are decoded with
|
|
294
|
+
`soundfile`; AAC and M4A (and any file `soundfile` can't read) fall back to PyAV,
|
|
295
|
+
which bundles ffmpeg. HEIC/HEIF/AVIF need `pillow-heif`, and SVG needs `cairosvg`
|
|
296
|
+
(which requires the Cairo library on some systems). GIF and multi-page TIFF use
|
|
297
|
+
the first frame; transparent images are composited on white.
|
|
298
|
+
|
|
299
|
+
Models load on CUDA when available, otherwise CPU.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Quick Start
|
|
304
|
+
|
|
305
|
+
After installing Modotte:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
pip install modotte
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
You can immediately use the supported models:
|
|
312
|
+
|
|
313
|
+
```python
|
|
314
|
+
from modotte import Audio, Image
|
|
315
|
+
|
|
316
|
+
audio_detector = Audio()
|
|
317
|
+
image_detector = Image()
|
|
318
|
+
|
|
319
|
+
audio_result = audio_detector.predict("audio.wav")
|
|
320
|
+
image_result = image_detector.predict("image.jpg")
|
|
321
|
+
|
|
322
|
+
print(audio_result)
|
|
323
|
+
print(image_result)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Development
|
|
329
|
+
|
|
330
|
+
Clone the repository:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
git clone https://github.com/Modotte/modotte-python.git
|
|
334
|
+
cd modotte-python
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Create a virtual environment:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
python -m venv .venv
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Activate it and install the package in editable mode:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
pip install -e .
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
After making changes to the source code, the changes will be available immediately in your environment.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
## Authors
|
|
353
|
+
|
|
354
|
+
- **Sujal Rajpoot** — [GitHub](https://github.com/sujalrajpoot)
|
|
355
|
+
- **Parvesh Rawal** — [GitHub](https://github.com/Parveshiiii)
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
See the [LICENSE](LICENSE) file for licensing information.
|
modotte-1.0.0/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# modotte-python
|
|
2
|
+
|
|
3
|
+
A universal Python package for accessing and using all AI models trained by Modotte.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Install from PyPI
|
|
8
|
+
|
|
9
|
+
Install the latest stable version directly from PyPI:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install modotte
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then import Modotte in your Python project:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from modotte import Audio, Image
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Upgrade to the latest version
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install --upgrade modotte
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Install from GitHub
|
|
30
|
+
|
|
31
|
+
You can also install the latest development version directly from GitHub:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install git+https://github.com/Modotte/modotte-python.git
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Clone the repository
|
|
38
|
+
|
|
39
|
+
If you want to develop or modify Modotte locally:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/Modotte/modotte-python.git
|
|
43
|
+
cd modotte-python
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Project Structure
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
modotte-python/
|
|
52
|
+
├── 📄 .gitignore
|
|
53
|
+
├── 📄 LICENSE
|
|
54
|
+
├── 📄 README.md
|
|
55
|
+
├── 📄 pyproject.toml
|
|
56
|
+
└── 📁 src/
|
|
57
|
+
└── 📁 modotte/
|
|
58
|
+
├── 📄 AIRealNet.py
|
|
59
|
+
├── 📄 __init__.py
|
|
60
|
+
├── 📄 _common.py ← internal
|
|
61
|
+
├── 📄 _formats.py ← internal
|
|
62
|
+
├── 📄 audio.py ← public API
|
|
63
|
+
└── 📄 image.py ← public API
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Hugging Face Token (Optional, Recommended)
|
|
67
|
+
|
|
68
|
+
The models are downloaded from the Hugging Face Hub on first use.
|
|
69
|
+
|
|
70
|
+
Without a token, you may see:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
Warning: You are sending unauthenticated requests to the HF Hub
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Unauthenticated requests are subject to lower rate limits. A free Hugging Face token can provide higher rate limits and more reliable downloads.
|
|
77
|
+
|
|
78
|
+
Create a token from:
|
|
79
|
+
|
|
80
|
+
https://huggingface.co/settings/tokens
|
|
81
|
+
|
|
82
|
+
There are three ways to provide it.
|
|
83
|
+
|
|
84
|
+
### 1. Pass the token directly
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from modotte import Audio, Image
|
|
88
|
+
|
|
89
|
+
detector = Audio(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
90
|
+
detector = Image(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 2. Set the `HF_TOKEN` environment variable
|
|
94
|
+
|
|
95
|
+
#### Windows PowerShell — current session
|
|
96
|
+
|
|
97
|
+
```powershell
|
|
98
|
+
$env:HF_TOKEN = "hf_xxxxxxxxxxxxxxxx"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Windows — permanent
|
|
102
|
+
|
|
103
|
+
```powershell
|
|
104
|
+
setx HF_TOKEN "hf_xxxxxxxxxxxxxxxx"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Open a new terminal after running `setx`.
|
|
108
|
+
|
|
109
|
+
#### macOS / Linux
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
export HF_TOKEN="hf_xxxxxxxxxxxxxxxx"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 3. Log in using the Hugging Face CLI
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
hf auth login
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
An explicit `hf_token=` argument takes priority over the `HF_TOKEN` environment variable.
|
|
122
|
+
|
|
123
|
+
The token is only used for downloading models. Modotte does not store or print your token.
|
|
124
|
+
|
|
125
|
+
Models are downloaded once and subsequently loaded from the local cache.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Audio Classification
|
|
130
|
+
|
|
131
|
+
Import the audio detector:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from modotte import Audio
|
|
135
|
+
|
|
136
|
+
detector = Audio()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
On first use, Modotte checks for the model locally and downloads it if necessary.
|
|
140
|
+
|
|
141
|
+
You can optionally provide a Hugging Face token:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
detector = Audio(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Detect Bonafide / Real Audio
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
result = detector.predict("bonafide.wav", threshold=0.5)
|
|
151
|
+
|
|
152
|
+
print(result["label"])
|
|
153
|
+
print(result["confidence"])
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Detect Spoof / AI-Generated Audio
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
result = detector.predict("spoof.wav", threshold=0.5)
|
|
160
|
+
|
|
161
|
+
print(result["label"])
|
|
162
|
+
print(result["confidence"])
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The `threshold` parameter must be a float between `0.0` and `1.0`, inclusive.
|
|
166
|
+
|
|
167
|
+
Invalid types such as integers, strings, or booleans raise `TypeError`.
|
|
168
|
+
|
|
169
|
+
Values outside the range `0.0`–`1.0` raise `ValueError`.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Image Classification
|
|
174
|
+
|
|
175
|
+
Import the image detector:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from modotte import Image
|
|
179
|
+
|
|
180
|
+
detector = Image()
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
On first use, Modotte checks for the model locally and downloads it if necessary.
|
|
184
|
+
|
|
185
|
+
You can optionally provide a Hugging Face token:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
detector = Image(hf_token="hf_xxxxxxxxxxxxxxxx")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Run a prediction:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
result = detector.predict("cat.jpg")
|
|
195
|
+
|
|
196
|
+
print(result["label"])
|
|
197
|
+
print(result["confidence"])
|
|
198
|
+
print(result["scores"])
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Example:
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
{
|
|
205
|
+
"label": "real",
|
|
206
|
+
"confidence": 0.94,
|
|
207
|
+
"scores": {
|
|
208
|
+
"artificial": 0.06,
|
|
209
|
+
"real": 0.94
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`Modotte/AIRealNet` is a binary SwinV2 Tiny classifier:
|
|
215
|
+
|
|
216
|
+
* Class 0: AI-generated
|
|
217
|
+
* Class 1: Real human image
|
|
218
|
+
|
|
219
|
+
Both import styles are supported:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from modotte import Audio, Image
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
and:
|
|
226
|
+
|
|
227
|
+
```python
|
|
228
|
+
from modotte.AIRealNet import Audio, Image
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Supported file types
|
|
234
|
+
|
|
235
|
+
- **Audio:** MP3, WAV, AAC, FLAC, OGG, Opus, M4A, AIFF
|
|
236
|
+
- **Image:** JPG, JPEG, PNG, WebP, GIF, SVG, BMP, TIFF, AVIF, HEIC, HEIF
|
|
237
|
+
|
|
238
|
+
Other extensions raise `ValueError`. WAV/FLAC/OGG/Opus/AIFF/MP3 are decoded with
|
|
239
|
+
`soundfile`; AAC and M4A (and any file `soundfile` can't read) fall back to PyAV,
|
|
240
|
+
which bundles ffmpeg. HEIC/HEIF/AVIF need `pillow-heif`, and SVG needs `cairosvg`
|
|
241
|
+
(which requires the Cairo library on some systems). GIF and multi-page TIFF use
|
|
242
|
+
the first frame; transparent images are composited on white.
|
|
243
|
+
|
|
244
|
+
Models load on CUDA when available, otherwise CPU.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Quick Start
|
|
249
|
+
|
|
250
|
+
After installing Modotte:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
pip install modotte
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
You can immediately use the supported models:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from modotte import Audio, Image
|
|
260
|
+
|
|
261
|
+
audio_detector = Audio()
|
|
262
|
+
image_detector = Image()
|
|
263
|
+
|
|
264
|
+
audio_result = audio_detector.predict("audio.wav")
|
|
265
|
+
image_result = image_detector.predict("image.jpg")
|
|
266
|
+
|
|
267
|
+
print(audio_result)
|
|
268
|
+
print(image_result)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Development
|
|
274
|
+
|
|
275
|
+
Clone the repository:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
git clone https://github.com/Modotte/modotte-python.git
|
|
279
|
+
cd modotte-python
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Create a virtual environment:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
python -m venv .venv
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Activate it and install the package in editable mode:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
pip install -e .
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
After making changes to the source code, the changes will be available immediately in your environment.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
## Authors
|
|
298
|
+
|
|
299
|
+
- **Sujal Rajpoot** — [GitHub](https://github.com/sujalrajpoot)
|
|
300
|
+
- **Parvesh Rawal** — [GitHub](https://github.com/Parveshiiii)
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
See the [LICENSE](LICENSE) file for licensing information.
|