Spaces:
Runtime error
Runtime error
Hentinel
commited on
Commit
•
4bfa117
0
Parent(s):
Duplicate from Hentinel/captchasolverkontankt
Browse files- .gitattributes +35 -0
- README.md +13 -0
- app.py +42 -0
- examples/1.jfif +0 -0
- examples/10.jfif +0 -0
- examples/11.jfif +0 -0
- examples/12.jfif +0 -0
- examples/2.jfif +0 -0
- examples/3.jfif +0 -0
- examples/4.jfif +0 -0
- examples/5.jfif +0 -0
- examples/6.jfif +0 -0
- examples/7.jfif +0 -0
- examples/8.jfif +0 -0
- examples/9.jfif +0 -0
- model.onnx +3 -0
- requirements.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Captchasolverkontankt
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.36.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: Hentinel/captchasolverkontankt
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import onnxruntime as onr
|
2 |
+
import numpy as np
|
3 |
+
import glob
|
4 |
+
import gradio as gr
|
5 |
+
characters = ['z', 's', 'h', 'q', 'd', 'v', '2', '7', '8', 'x', 'y', '5', 'e', 'a', 'u', '4', 'k', 'n', 'm', 'c', 'p']
|
6 |
+
img_width = 130
|
7 |
+
img_height = 50
|
8 |
+
max_length = 7
|
9 |
+
Model = onr.InferenceSession('model.onnx')
|
10 |
+
ModelName = Model.get_inputs()[0].name
|
11 |
+
def solve_task(img):
|
12 |
+
img = img.astype(np.float32) / 255.
|
13 |
+
img = img.transpose([1, 0, 2])
|
14 |
+
img = np.array([img])
|
15 |
+
result_tensor = Model.run(None, {ModelName: img})[0]
|
16 |
+
answer, accuracy = get_result(result_tensor)
|
17 |
+
|
18 |
+
return answer
|
19 |
+
def get_result(pred):
|
20 |
+
accuracy = 1
|
21 |
+
last = None
|
22 |
+
ans = []
|
23 |
+
for item in pred[0]:
|
24 |
+
char_ind = item.argmax()
|
25 |
+
if char_ind != last and char_ind != 0 and char_ind != len(characters) + 1:
|
26 |
+
ans.append(characters[char_ind - 1])
|
27 |
+
accuracy *= item[char_ind]
|
28 |
+
last = char_ind
|
29 |
+
answ = "".join(ans)[:max_length]
|
30 |
+
return answ, accuracy
|
31 |
+
|
32 |
+
|
33 |
+
title = "captcha solver"
|
34 |
+
description = "hate captcha"
|
35 |
+
|
36 |
+
iface = gr.Interface(fn=solve_task,
|
37 |
+
inputs=gr.inputs.Image((img_width, img_height)),
|
38 |
+
outputs=gr.outputs.Textbox(),
|
39 |
+
title=title,
|
40 |
+
examples=glob.glob('examples/*.jfif'),
|
41 |
+
description=description)
|
42 |
+
iface.launch()
|
examples/1.jfif
ADDED
Binary file (4.19 kB). View file
|
|
examples/10.jfif
ADDED
Binary file (2.88 kB). View file
|
|
examples/11.jfif
ADDED
Binary file (2.48 kB). View file
|
|
examples/12.jfif
ADDED
Binary file (2.69 kB). View file
|
|
examples/2.jfif
ADDED
Binary file (3.73 kB). View file
|
|
examples/3.jfif
ADDED
Binary file (4.45 kB). View file
|
|
examples/4.jfif
ADDED
Binary file (4.54 kB). View file
|
|
examples/5.jfif
ADDED
Binary file (4.09 kB). View file
|
|
examples/6.jfif
ADDED
Binary file (2.79 kB). View file
|
|
examples/7.jfif
ADDED
Binary file (2.87 kB). View file
|
|
examples/8.jfif
ADDED
Binary file (2.84 kB). View file
|
|
examples/9.jfif
ADDED
Binary file (2.56 kB). View file
|
|
model.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:15bdf1eb90a0f98cc74f3f231a7380c32d6409d87e804f5980d9f2542a49c475
|
3 |
+
size 1756226
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
onnxruntime==1.15.1
|