Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,7 @@ TOKEN = os.getenv('hf_read_token')
|
|
| 9 |
repo_id = "Nischay103/captcha_recognition"
|
| 10 |
model_file = 'captcha_model.pt'
|
| 11 |
model_path = hf_hub_download(repo_id=repo_id, filename=model_file, token=TOKEN)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
charset = r"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
| 15 |
_tokenizer = Tokenizer(charset)
|
| 16 |
|
| 17 |
def get_transform(img_size=(32,128)):
|
|
@@ -24,9 +22,8 @@ def get_transform(img_size=(32,128)):
|
|
| 24 |
return T.Compose(transforms)
|
| 25 |
|
| 26 |
transform = get_transform()
|
| 27 |
-
image = gr.Image(type="
|
| 28 |
-
text
|
| 29 |
-
|
| 30 |
|
| 31 |
def recognize_captcha(image_path):
|
| 32 |
input = Image.open(image_path)
|
|
@@ -38,13 +35,13 @@ def recognize_captcha(image_path):
|
|
| 38 |
return preds[0]
|
| 39 |
|
| 40 |
iface = gr.Interface(
|
| 41 |
-
fn=recognize_captcha,
|
| 42 |
-
inputs=image,
|
| 43 |
-
outputs=text,
|
| 44 |
-
title="character sequence recognition from scene-image (captcha)",
|
| 45 |
-
description="recognize captchas ",
|
| 46 |
-
examples=['examples/251615.png','examples/e7dx2r.jpg','examples/980209.png','examples/2DMM4.png',
|
| 47 |
-
|
| 48 |
)
|
| 49 |
|
| 50 |
iface.launch()
|
|
|
|
| 9 |
repo_id = "Nischay103/captcha_recognition"
|
| 10 |
model_file = 'captcha_model.pt'
|
| 11 |
model_path = hf_hub_download(repo_id=repo_id, filename=model_file, token=TOKEN)
|
| 12 |
+
charset = r"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
|
|
|
| 13 |
_tokenizer = Tokenizer(charset)
|
| 14 |
|
| 15 |
def get_transform(img_size=(32,128)):
|
|
|
|
| 22 |
return T.Compose(transforms)
|
| 23 |
|
| 24 |
transform = get_transform()
|
| 25 |
+
image = gr.Image(type="pil", label="captcha image")
|
| 26 |
+
text = gr.Textbox(label="recognized character sequence")
|
|
|
|
| 27 |
|
| 28 |
def recognize_captcha(image_path):
|
| 29 |
input = Image.open(image_path)
|
|
|
|
| 35 |
return preds[0]
|
| 36 |
|
| 37 |
iface = gr.Interface(
|
| 38 |
+
fn = recognize_captcha,
|
| 39 |
+
inputs = image,
|
| 40 |
+
outputs= text,
|
| 41 |
+
title = "character sequence recognition from scene-image (captcha)",
|
| 42 |
+
description = "recognize captchas ",
|
| 43 |
+
examples = ['examples/251615.png','examples/e7dx2r.jpg','examples/980209.png','examples/2DMM4.png',
|
| 44 |
+
'examples/H1GQD.png','examples/Sv5Cwm.jpg','examples/Wwx7.png','examples/qw7vr.png']
|
| 45 |
)
|
| 46 |
|
| 47 |
iface.launch()
|