Spaces:
Running
Running
Commit ·
e231144
0
Parent(s):
Duplicate from Hentinel/pixelplanet_captcha
Browse files- .gitattributes +35 -0
- README.md +13 -0
- app.py +52 -0
- examples/0.png +0 -0
- examples/1.png +0 -0
- examples/10.png +0 -0
- examples/11.png +0 -0
- examples/12.png +0 -0
- examples/13.png +0 -0
- examples/14.png +0 -0
- examples/15.png +0 -0
- examples/16.png +0 -0
- examples/17.png +0 -0
- examples/18.png +0 -0
- examples/19.png +0 -0
- examples/2.png +0 -0
- examples/20.png +0 -0
- examples/21.png +0 -0
- examples/22.png +0 -0
- examples/23.png +0 -0
- examples/3.png +0 -0
- examples/4.png +0 -0
- examples/5.png +0 -0
- examples/6.png +0 -0
- examples/7.png +0 -0
- examples/8.png +0 -0
- examples/9.png +0 -0
- model.onnx +3 -0
- requirements.txt +2 -0
- vermei_slaves.h5 +3 -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: Pixelplanet Captcha
|
| 3 |
+
emoji: 🏃
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: pink
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.36.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
duplicated_from: Hentinel/pixelplanet_captcha
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import onnxruntime as onr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import glob
|
| 5 |
+
#----- CONFIG ------
|
| 6 |
+
img_height = 300
|
| 7 |
+
img_width = 500
|
| 8 |
+
max_length = 4
|
| 9 |
+
characters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
|
| 10 |
+
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
| 11 |
+
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
|
| 12 |
+
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
|
| 13 |
+
'y', 'z'
|
| 14 |
+
]
|
| 15 |
+
model_path = 'model.onnx'
|
| 16 |
+
#===== some code init =====
|
| 17 |
+
Model = onr.InferenceSession(model_path)
|
| 18 |
+
|
| 19 |
+
#===== some funcs =====
|
| 20 |
+
def get_result(pred):
|
| 21 |
+
accuracy = 1
|
| 22 |
+
last = None
|
| 23 |
+
ans = []
|
| 24 |
+
for item in pred[0]:
|
| 25 |
+
char_ind = item.argmax()
|
| 26 |
+
if char_ind != last and char_ind != 0 and char_ind != len(characters) + 1:
|
| 27 |
+
ans.append(characters[char_ind - 1])
|
| 28 |
+
accuracy *= item[char_ind]
|
| 29 |
+
last = char_ind
|
| 30 |
+
answ = "".join(ans)[:max_length]
|
| 31 |
+
return answ, accuracy
|
| 32 |
+
def predict(img):
|
| 33 |
+
img = img.convert('L')
|
| 34 |
+
img = img.resize((img_width, img_height))
|
| 35 |
+
img = np.array(img)
|
| 36 |
+
img = np.expand_dims(img, axis=1)
|
| 37 |
+
img = np.expand_dims(img, axis=-1)
|
| 38 |
+
img = img.transpose([1,2,0,3])
|
| 39 |
+
img = img.astype(np.float32) / 255.
|
| 40 |
+
result_tensor = Model.run(None, {'image': img, 'label': np.random.default_rng().random((28, 28), dtype=np.float32)})[0]
|
| 41 |
+
return (get_result(result_tensor)[0])
|
| 42 |
+
|
| 43 |
+
title = "Made with love❤️❤️❤️❤️\nby Vermei"
|
| 44 |
+
description = "read meinkampf first"
|
| 45 |
+
|
| 46 |
+
iface = gr.Interface(fn=predict,
|
| 47 |
+
inputs=gr.inputs.Image(type='pil'),
|
| 48 |
+
outputs=gr.outputs.Textbox(),
|
| 49 |
+
title=title,
|
| 50 |
+
examples=glob.glob('examples/*.png'),
|
| 51 |
+
description=description)
|
| 52 |
+
iface.launch()
|
examples/0.png
ADDED
|
|
examples/1.png
ADDED
|
|
examples/10.png
ADDED
|
|
examples/11.png
ADDED
|
|
examples/12.png
ADDED
|
|
examples/13.png
ADDED
|
|
examples/14.png
ADDED
|
|
examples/15.png
ADDED
|
|
examples/16.png
ADDED
|
|
examples/17.png
ADDED
|
|
examples/18.png
ADDED
|
|
examples/19.png
ADDED
|
|
examples/2.png
ADDED
|
|
examples/20.png
ADDED
|
|
examples/21.png
ADDED
|
|
examples/22.png
ADDED
|
|
examples/23.png
ADDED
|
|
examples/3.png
ADDED
|
|
examples/4.png
ADDED
|
|
examples/5.png
ADDED
|
|
examples/6.png
ADDED
|
|
examples/7.png
ADDED
|
|
examples/8.png
ADDED
|
|
examples/9.png
ADDED
|
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26cec4eda2fc18613b458b3f4d022a24a27897af21938ef340dd279cc0565390
|
| 3 |
+
size 2808688
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
onnx==1.14.0
|
| 2 |
+
onnxruntime==1.15.1
|
vermei_slaves.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63b892cb6d4b51808dfe4ba3089fbdf25f7e590f42edf11bc7e67fb8f0786278
|
| 3 |
+
size 8451176
|