feat: Update signature detection parameters and enhance Gradio interface with dynamic example loading
Browse files- app.py +7 -14
- assets/images/example_5.jpg +0 -0
- assets/images/example_7.jpg +0 -0
app.py
CHANGED
|
@@ -136,7 +136,7 @@ class SignatureDetector:
|
|
| 136 |
|
| 137 |
return cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
|
| 138 |
|
| 139 |
-
def detect(self, image, conf_thres, iou_thres):
|
| 140 |
# Preprocess the image
|
| 141 |
img_data, original_image = self.preprocess(image)
|
| 142 |
|
|
@@ -177,10 +177,7 @@ def create_gradio_interface():
|
|
| 177 |
) as iface:
|
| 178 |
gr.Markdown(
|
| 179 |
"""
|
| 180 |
-
|
| 181 |
-
<img src="https://cdn.prod.website-files.com/65155fabb679475d43638cde/65396826ed65fb2d37f242cf_tech4humans.png" alt="logo" style="width: 50px; height: 50px; margin-right: 15px; vertical-align: middle;">
|
| 182 |
-
<span style="font-size: 24px; font-weight: bold;">Tech4Humans - Detector de Assinaturas</span>
|
| 183 |
-
</div>
|
| 184 |
|
| 185 |
Este sistema utiliza o modelo [**YOLOv8s**](https://huggingface.co/tech4humans/yolov8s-signature-detector), especialmente ajustado para a detecção de assinaturas manuscritas em imagens de documentos.
|
| 186 |
O modelo foi treinado com dados provenientes de dois conjuntos públicos — [**Tobacco800**](https://paperswithcode.com/dataset/tobacco-800) e [**signatures-xc8up**](https://universe.roboflow.com/roboflow-100/signatures-xc8up) — e inclui robustos
|
|
@@ -204,7 +201,7 @@ def create_gradio_interface():
|
|
| 204 |
confidence_threshold = gr.Slider(
|
| 205 |
minimum=0.0,
|
| 206 |
maximum=1.0,
|
| 207 |
-
value=0.
|
| 208 |
step=0.05,
|
| 209 |
label="Limiar de Confiança",
|
| 210 |
info="Ajuste a pontuação mínima de confiança necessária para detecção."
|
|
@@ -221,21 +218,17 @@ def create_gradio_interface():
|
|
| 221 |
output_image = gr.Image(label="Resultados da Detecção") # Em outra coluna
|
| 222 |
|
| 223 |
clear_btn.add(output_image)
|
| 224 |
-
|
| 225 |
gr.Examples(
|
| 226 |
examples=[
|
| 227 |
-
["assets/images/
|
| 228 |
-
["assets/images/example_2.jpg"],
|
| 229 |
-
["assets/images/example_3.jpg"],
|
| 230 |
-
["assets/images/example_4.jpg"],
|
| 231 |
-
["assets/images/example_5.jpg"],
|
| 232 |
-
["assets/images/example_6.jpg"]
|
| 233 |
],
|
| 234 |
inputs=input_image,
|
| 235 |
outputs=output_image,
|
| 236 |
fn=detector.detect,
|
| 237 |
label="Exemplos",
|
| 238 |
-
cache_examples=
|
|
|
|
| 239 |
)
|
| 240 |
|
| 241 |
|
|
|
|
| 136 |
|
| 137 |
return cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
|
| 138 |
|
| 139 |
+
def detect(self, image, conf_thres=0.25, iou_thres=0.5):
|
| 140 |
# Preprocess the image
|
| 141 |
img_data, original_image = self.preprocess(image)
|
| 142 |
|
|
|
|
| 177 |
) as iface:
|
| 178 |
gr.Markdown(
|
| 179 |
"""
|
| 180 |
+
# Tech4Humans - Detector de Assinaturas
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
Este sistema utiliza o modelo [**YOLOv8s**](https://huggingface.co/tech4humans/yolov8s-signature-detector), especialmente ajustado para a detecção de assinaturas manuscritas em imagens de documentos.
|
| 183 |
O modelo foi treinado com dados provenientes de dois conjuntos públicos — [**Tobacco800**](https://paperswithcode.com/dataset/tobacco-800) e [**signatures-xc8up**](https://universe.roboflow.com/roboflow-100/signatures-xc8up) — e inclui robustos
|
|
|
|
| 201 |
confidence_threshold = gr.Slider(
|
| 202 |
minimum=0.0,
|
| 203 |
maximum=1.0,
|
| 204 |
+
value=0.25,
|
| 205 |
step=0.05,
|
| 206 |
label="Limiar de Confiança",
|
| 207 |
info="Ajuste a pontuação mínima de confiança necessária para detecção."
|
|
|
|
| 218 |
output_image = gr.Image(label="Resultados da Detecção") # Em outra coluna
|
| 219 |
|
| 220 |
clear_btn.add(output_image)
|
| 221 |
+
|
| 222 |
gr.Examples(
|
| 223 |
examples=[
|
| 224 |
+
["assets/images/example_{i}.jpg".format(i=i)] for i in range(1, len(os.listdir(os.path.join("assets", "images")))+1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
],
|
| 226 |
inputs=input_image,
|
| 227 |
outputs=output_image,
|
| 228 |
fn=detector.detect,
|
| 229 |
label="Exemplos",
|
| 230 |
+
cache_examples=True,
|
| 231 |
+
cache_mode='lazy'
|
| 232 |
)
|
| 233 |
|
| 234 |
|
assets/images/example_5.jpg
CHANGED
|
|
assets/images/example_7.jpg
ADDED
|