Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
import numpy as np
|
|
@@ -46,59 +47,25 @@ def generate_mask(image):
|
|
| 46 |
|
| 47 |
return mask_image
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
|
| 51 |
-
css = """
|
| 52 |
-
.app-container { background-color: white; }
|
| 53 |
-
.title-container {
|
| 54 |
-
background-color: white;
|
| 55 |
-
display: flex;
|
| 56 |
-
align-items: center;
|
| 57 |
-
justify-content: center;
|
| 58 |
-
height: 300px;
|
| 59 |
-
font-size: 24px;
|
| 60 |
-
font-weight: bold;
|
| 61 |
-
text-align: center;
|
| 62 |
-
}
|
| 63 |
-
.centered-image {
|
| 64 |
-
display: block;
|
| 65 |
-
margin: auto;
|
| 66 |
-
}
|
| 67 |
-
"""
|
| 68 |
-
with gr.Blocks(css=css) as demo:
|
| 69 |
-
# Fila con t铆tulo en rect谩ngulo y logo en dos columnas
|
| 70 |
-
with gr.Row():
|
| 71 |
-
gr.Image(value="Cacaotin.png", width=300, height=300, elem_id="centered-image")
|
| 72 |
-
gr.Markdown("<div class='title-container'>Fermentation Level Classification for Cocoa Beans</div>")
|
| 73 |
-
|
| 74 |
-
# Bot贸n GitHub centrado
|
| 75 |
-
gr.Markdown("<center><a href='https://github.com/kebincontreras/cocoa_beans_interfaces' target='_blank'><button style='background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 5px; font-size: 16px;'>View on GitHub</button></a></center>")
|
| 76 |
-
|
| 77 |
-
# Organizar im谩genes de carga y procesadas en la misma fila
|
| 78 |
-
with gr.Row():
|
| 79 |
-
img_input = gr.Image(label="Upload Image", examples=["/mnt/data/cacao_1.png", "/mnt/data/cacao_2.jpg"])
|
| 80 |
-
img_output = gr.Image(label="Image with Generated Mask")
|
| 81 |
-
|
| 82 |
-
# Bot贸n para generar la m谩scara
|
| 83 |
-
btn_classify = gr.Button("Generate Mask for Fermentation Level")
|
| 84 |
-
btn_classify.click(generate_mask, inputs=img_input, outputs=img_output)
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
**Cacao Classes According to NTC1252:2021:**
|
| 89 |
- **a) Well-fermented:** Optimal fermentation process.
|
| 90 |
- **b) Partially fermented:** Incomplete fermentation process.
|
| 91 |
- **c) Non-fermented:** Lack of adequate fermentation.
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
gr.Markdown("**Explanation According to NTC1252:2021:** Here you can explain how the NTC1252:2021 norm applies to the classification of fermentation levels.")
|
| 97 |
-
|
| 98 |
-
return demo
|
| 99 |
|
| 100 |
# Ejecutar la aplicaci贸n
|
| 101 |
if __name__ == "__main__":
|
| 102 |
-
|
| 103 |
-
demo.launch()
|
| 104 |
-
|
|
|
|
| 1 |
+
|
| 2 |
import gradio as gr
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
|
|
|
| 47 |
|
| 48 |
return mask_image
|
| 49 |
|
| 50 |
+
# Crear la interfaz con ejemplos
|
| 51 |
+
examples = [["cacao_1.png"], ["cacao_2.jpg"]] # Aseg煤rate de que estos archivos est茅n en la misma carpeta que el script
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
iface = gr.Interface(
|
| 54 |
+
fn=generate_mask,
|
| 55 |
+
inputs=gr.Image(label="Upload Image"),
|
| 56 |
+
outputs=gr.Image(label="Image with Generated Mask"),
|
| 57 |
+
title="Fermentation Level Classification for Cocoa Beans",
|
| 58 |
+
examples=examples,
|
| 59 |
+
description="""
|
| 60 |
**Cacao Classes According to NTC1252:2021:**
|
| 61 |
- **a) Well-fermented:** Optimal fermentation process.
|
| 62 |
- **b) Partially fermented:** Incomplete fermentation process.
|
| 63 |
- **c) Non-fermented:** Lack of adequate fermentation.
|
| 64 |
+
|
| 65 |
+
**Explanation According to NTC1252:2021:** Here you can explain how the NTC1252:2021 norm applies to the classification of fermentation levels.
|
| 66 |
+
"""
|
| 67 |
+
)
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
# Ejecutar la aplicaci贸n
|
| 70 |
if __name__ == "__main__":
|
| 71 |
+
iface.launch()
|
|
|
|
|
|