akhaliq HF staff commited on
Commit
25e4693
1 Parent(s): 4b6a42f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import CaptchaCracker as cc
3
+
4
+
5
+ # Target image data size
6
+ img_width = 200
7
+ img_height = 50
8
+ # Target image label length
9
+ max_length = 6
10
+ # Target image label component
11
+ characters = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
12
+
13
+ # Model weight file path
14
+ weights_path = "weights.h5"
15
+ # Creating a model application instance
16
+ AM = cc.ApplyModel(weights_path, img_width, img_height, max_length, characters)
17
+
18
+ def inference(target_img_path):
19
+ # Predicted value
20
+ pred = AM.predict(target_img_path)
21
+ return pred
22
+
23
+
24
+
25
+ block = gr.Blocks()
26
+
27
+ with block:
28
+ gr.Markdown("Gradio Demo for WooilJeong/CaptchaCracker")
29
+
30
+ with gr.Tabs():
31
+ with gr.TabItem("CaptchaCracker"):
32
+ with gr.Row():
33
+ captchaimg = gr.inputs.Image(type="filepath")
34
+ text = gr.outputs.Textbox()
35
+ catch_run = gr.Button("Run")
36
+ catch_run.click(inference, inputs=captchaimg, outputs=text)
37
+
38
+ block.launch()