File size: 841 Bytes
a2c6b4a
 
 
 
 
 
e09cfdf
a2c6b4a
d6260eb
a2c6b4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

import gradio as gr
import yolov5
from PIL import Image

app_title = "Aksara Jawa Layout Detection"
models_id = 'hermanshid/yolo-layout-detector'

model = yolov5.load(models_id)

examples = [['test_images/example1.jpg', 0.6, ]]


def predict(image, threshold=0.25):
    global models_id
    global model

    input_size = 640

    model.conf = threshold
    results = model(image, size=input_size)
    numpy_image = results.render()[0]
    output_image = Image.fromarray(numpy_image)
    return output_image


gr.Interface(
    title=app_title,
    description="Created by 'hermanshid'",
    fn=predict,
    inputs=[
        gr.Image(type="pil"),
        gr.Slider(maximum=1, step=0.01, value=0.25),
    ],
    outputs=gr.Image(type="pil"),
    examples=examples,
    cache_examples=True if examples else False,
).launch(enable_queue=True)