import gradio as gr
import CaptchaCracker as cc
# Target image data size
img_width = 200
img_height = 50
# Target image label length
max_length = 6
# Target image label component
characters = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
# Model weight file path
weights_path = "weights.h5"
# Creating a model application instance
AM = cc.ApplyModel(weights_path, img_width, img_height, max_length, characters)
def inference(target_img_path):
# Predicted value
pred = AM.predict(target_img_path)
return pred
block = gr.Blocks()
with block:
gr.Markdown("Gradio Demo for WooilJeong/CaptchaCracker")
with gr.Tabs():
with gr.TabItem("CaptchaCracker"):
with gr.Row():
captchaimg = gr.inputs.Image(type="filepath")
text = gr.outputs.Textbox()
catch_run = gr.Button("Run")
catch_run.click(inference, inputs=captchaimg, outputs=text)
block.launch()