Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -104,22 +104,12 @@ def set_example_url(example: list) -> dict:
|
|
104 |
|
105 |
title = """<h1 id="title">License Plate Detection with YOLOS</h1>"""
|
106 |
|
107 |
-
|
108 |
-
YOLOS is a Vision Transformer (ViT) trained using the DETR loss. Despite its simplicity, a base-sized YOLOS model is able to achieve 42 AP on COCO validation 2017 (similar to DETR and more complex frameworks such as Faster R-CNN).
|
109 |
-
The YOLOS model was fine-tuned on COCO 2017 object detection (118k annotated images). It was introduced in the paper [You Only Look at One Sequence: Rethinking Transformer in Vision through Object Detection](https://arxiv.org/abs/2106.00666) by Fang et al. and first released in [this repository](https://github.com/hustvl/YOLOS).
|
110 |
-
This model was further fine-tuned on the [Car license plate dataset]("https://www.kaggle.com/datasets/andrewmvd/car-plate-detection") from Kaggle. The dataset consists of 443 images of vehicle with annotations categorised as "Vehicle" and "Rego Plates". The model was trained for 200 epochs on a single GPU.
|
111 |
-
Links to HuggingFace Models:
|
112 |
-
- [nickmuchi/yolos-small-rego-plates-detection](https://huggingface.co/nickmuchi/yolos-small-rego-plates-detection)
|
113 |
-
- [hustlv/yolos-small](https://huggingface.co/hustlv/yolos-small)
|
114 |
-
"""
|
115 |
|
116 |
models = ["nickmuchi/yolos-small-finetuned-license-plate-detection","nickmuchi/detr-resnet50-license-plate-detection"]
|
117 |
urls = ["https://drive.google.com/uc?id=1j9VZQ4NDS4gsubFf3m2qQoTMWLk552bQ","https://drive.google.com/uc?id=1p9wJIqRz3W50e2f_A0D8ftla8hoXz4T5"]
|
118 |
images = [[path.as_posix()] for path in sorted(pathlib.Path('images').rglob('*.j*g'))]
|
119 |
-
|
120 |
-
twitter_link = """
|
121 |
-
[](https://twitter.com/nickmuchi)
|
122 |
-
"""
|
123 |
|
124 |
css = '''
|
125 |
h1#title {
|
@@ -129,9 +119,7 @@ h1#title {
|
|
129 |
demo = gr.Blocks(css=css)
|
130 |
|
131 |
with demo:
|
132 |
-
gr.Markdown(title)
|
133 |
-
gr.Markdown(description)
|
134 |
-
gr.Markdown(twitter_link)
|
135 |
options = gr.Dropdown(choices=models,label='Object Detection Model',value=models[0],show_label=True)
|
136 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,step=0.1,label='Prediction Threshold')
|
137 |
|
@@ -140,10 +128,10 @@ with demo:
|
|
140 |
with gr.Row():
|
141 |
with gr.Column():
|
142 |
url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
|
143 |
-
original_image = gr.Image(
|
144 |
url_input.change(get_original_image, url_input, original_image)
|
145 |
with gr.Column():
|
146 |
-
img_output_from_url = gr.Image(
|
147 |
|
148 |
with gr.Row():
|
149 |
example_url = gr.Examples(examples=urls,inputs=[url_input])
|
@@ -153,8 +141,8 @@ with demo:
|
|
153 |
|
154 |
with gr.TabItem('Image Upload'):
|
155 |
with gr.Row():
|
156 |
-
img_input = gr.Image(type='pil'
|
157 |
-
img_output_from_upload= gr.Image(
|
158 |
|
159 |
with gr.Row():
|
160 |
example_images = gr.Examples(examples=images,inputs=[img_input])
|
@@ -164,8 +152,8 @@ with demo:
|
|
164 |
|
165 |
with gr.TabItem('WebCam'):
|
166 |
with gr.Row():
|
167 |
-
web_input = gr.Image(source='webcam',type='pil',
|
168 |
-
img_output_from_webcam= gr.Image(
|
169 |
|
170 |
cam_but = gr.Button('Detect')
|
171 |
|
|
|
104 |
|
105 |
title = """<h1 id="title">License Plate Detection with YOLOS</h1>"""
|
106 |
|
107 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
models = ["nickmuchi/yolos-small-finetuned-license-plate-detection","nickmuchi/detr-resnet50-license-plate-detection"]
|
110 |
urls = ["https://drive.google.com/uc?id=1j9VZQ4NDS4gsubFf3m2qQoTMWLk552bQ","https://drive.google.com/uc?id=1p9wJIqRz3W50e2f_A0D8ftla8hoXz4T5"]
|
111 |
images = [[path.as_posix()] for path in sorted(pathlib.Path('images').rglob('*.j*g'))]
|
112 |
+
|
|
|
|
|
|
|
113 |
|
114 |
css = '''
|
115 |
h1#title {
|
|
|
119 |
demo = gr.Blocks(css=css)
|
120 |
|
121 |
with demo:
|
122 |
+
gr.Markdown(title)
|
|
|
|
|
123 |
options = gr.Dropdown(choices=models,label='Object Detection Model',value=models[0],show_label=True)
|
124 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,step=0.1,label='Prediction Threshold')
|
125 |
|
|
|
128 |
with gr.Row():
|
129 |
with gr.Column():
|
130 |
url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
|
131 |
+
original_image = gr.Image()
|
132 |
url_input.change(get_original_image, url_input, original_image)
|
133 |
with gr.Column():
|
134 |
+
img_output_from_url = gr.Image()
|
135 |
|
136 |
with gr.Row():
|
137 |
example_url = gr.Examples(examples=urls,inputs=[url_input])
|
|
|
141 |
|
142 |
with gr.TabItem('Image Upload'):
|
143 |
with gr.Row():
|
144 |
+
img_input = gr.Image(type='pil')
|
145 |
+
img_output_from_upload= gr.Image()
|
146 |
|
147 |
with gr.Row():
|
148 |
example_images = gr.Examples(examples=images,inputs=[img_input])
|
|
|
152 |
|
153 |
with gr.TabItem('WebCam'):
|
154 |
with gr.Row():
|
155 |
+
web_input = gr.Image(source='webcam',type='pil',streaming=True)
|
156 |
+
img_output_from_webcam= gr.Image()
|
157 |
|
158 |
cam_but = gr.Button('Detect')
|
159 |
|